华恩JAVA班第38天

华恩JAVA班第38天

 我行我素购物管理系统

package com.zjj;

 *文件名称:Admin.java
 *功能说明:
 *开发人员:Ziu Ginzeon
 *创建时间:2013年8月3日 下午2:31:03
 
public class Admin{
 
 private String name;
 private String password;
 
 public Admin(String name, String password) {
  this.name = name;
  this.password = password;
 }

 public String getName() {
  return name;
 }

 public void setName(String name) {
  this.name = name;
 }

 public String getPassword() {
  return password;
 }

 public void setPassword(String password) {
  this.password = password;
 }
}

 


package com.zjj;

 *文件名称:Person.java
 *功能说明:
 *开发人员:Ziu Ginzeon
 *创建时间:2013年8月3日 下午12:19:16
 
public class Person {
 private String id;
 private int year;
 private String month;
 private String day;
 private int score = 0;
 
 public Person(String id, int year, String month, String day, int score) {
  super();
  this.id = id;
  this.year = year;
  this.month = month;
  this.day = day;
  this.score = score;
 }

 public String getId() {
  return id;
 }

 public void setId(String id) {
  this.id = id;
 }

 public int getYear() {
  return year;
 }

 public void setYear(int year) {
  this.year = year;
 }

 public String getMonth() {
  return month;
 }

 public void setMonth(String month) {
  this.month = month;
 }

 public String getDay() {
  return day;
 }

 public void setDay(String day) {
  this.day = day;
 }

 public int getScore() {
  return score;
 }

 public void setScore(int score) {
  this.score = score;
 }

}

 

 

package com.zjj;

 *文件名称:Commodity.java
 *功能说明:
 *开发人员:Ziu Ginzeon
 *创建时间:2013年8月3日 下午3:53:38
 
public class Commodity {
 private String name;
 private double money;

 public Commodity(String name, double money) {
  super();
  this.name = name;
  this.money = money;
 }

 public String getName() {
  return name;
 }

 public void setName(String name) {
  this.name = name;
 }

 public double getMoney() {
  return money;
 }

 public void setMoney(double money) {
  this.money = money;
 }
}

 

 

package com.zjj;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;

 


 *文件名称:ShoppingSystemTest.java
 *功能说明:
 *开发人员:Ziu Ginzeon
 *创建时间:2013年8月3日 下午12:21:47
 
public class ShoppingSystemTest {

 public static void main(String[] args) {
  // TODO Auto-generated method stub

  Scanner in = new Scanner(System.in);
  String word ;
  Admin admin = new Admin("zxc","123456");
  ArrayList arrayList = new ArrayList();
  arrayList.add(new Person("10001",1993,"09","08",0));
  System.out.println("\t欢迎使用我行我素购物管理系统1.0版");
  while(true){
   System.out.println("****************************************\n"+
        "\t\t1.登录系统\n"+
        "\t\t2.更改管理员密码\n"+
        "\t\t3.退出\n"+
        "****************************************");
   System.out.println("请选择,输入数字:");
   int a = in.nextInt();
   if(a == 1){
    while(true){
     System.out.println("请输入用户名:");
     String name = in.next();
     System.out.println("请输入密码:");
     String password = in.next();
     if(name.equals(admin.getName())&&password.equals(admin.getPassword())){
      System.out.println("登录成功");
      break;
     }else{
      System.out.println("输入错误,请重新输入");
     }
    }
    System.out.println("\t欢迎使用我行我素购物管理系统");
    while(true){
     System.out.println("****************************************\n"+
          "\t\t1.客户信息管理\n"+
          "\t\t2.购物结算\n"+
          "\t\t3.真情回馈\n"+
          "\t\t4.注销\n"+
          "****************************************\n"+
          "请选择,输入数字:");
     int b = in.nextInt();
     if(b == 1){
      while(true){
       System.out.println("我行我素购物管理系统->客户信息管理");
       System.out.println("****************************************\n"+
            "\t\t1.显示所有客户信息\n"+
            "\t\t2.添加客户信息\n"+
            "\t\t3.修改客户信息\n"+
            "\t\t4.查询客户信息\n"+
            "****************************************\n"+
            "请选择,输入数字或输入“n”返回");
       String c = in.next();
       if(c.equals("1")){
        System.out.println("我行我素购物管理系统->客户信息管理->显示所有客户信息");
        System.out.println("会员号\t生日\t\t积分");
        Iterator itor = arrayList.iterator();
        while(itor.hasNext()){
         Person person = itor.next();
         System.out.println(person.getId()+"\t"+
              person.getYear()+"-"+
              person.getMonth()+"-"+
              person.getDay()+"\t"+
              person.getScore());
        }
        System.out.println("输入任意值返回");
        if(in.next().equals("n")){
         continue;
        }
       }else if(c.equals("2")){
        System.out.println("我行我素购物管理系统->客户信息管理->添加客户信息");
        System.out.println("请输入会员号:");
        String id = in.next();
        System.out.println("请输入生日的year(yyyy):");
        int y = in.nextInt();
        System.out.println("请输入新生日的month(mm):");
        String m = in.next();
        System.out.println("请输入新生日的day(dd):");
        String d = in.next();
        arrayList.add(new Person(id,y,m,d,0));
        System.out.println("添加成功\n"+"输入任意值返回");
        if(in.next().equals("n")){
         continue;
        }
       }else if(c.equals("3")){
        System.out.println("我行我素购物管理系统->客户信息管理->修改客户信息\n"+
             "请输入要修改的会员号:");
        boolean flag =true;
        while(flag){
         String id = in.next();
         for(int i=0;i
          if(id.equals(arrayList.get(i).getId())){
           System.out.println("请输入新生日的year(yyyy):");
           arrayList.get(i).setYear(in.nextInt());
           System.out.println("请输入新生日的month(mm):");
           arrayList.get(i).setMonth(in.next());
           System.out.println("请输入新生日的day(dd):");
           arrayList.get(i).setDay(in.next());
           System.out.println("修改成功");
           flag = false;
          }
         }
         if(flag){
          System.out.println("该会员号不存在,请在次输入要修改的会员号");
         }
        }
        System.out.println("输入任意值返回");
        if(in.next().equals("n")){
         continue;
        }
       }else if(c.equals("4")){
        System.out.println("我行我素购物管理系统->客户信息管理->查询客户信息\n"+
             "请输入要查询的会员号:");
        boolean flag =true;
        while(flag){
         String id = in.next();
         for(int i=0;i
          if(id.equals(arrayList.get(i).getId())){
           System.out.println("会员"+id+"的信息:"+
             "生日为:"+arrayList.get(i).getYear()+"-"+
             arrayList.get(i).getMonth()+"-"+
             arrayList.get(i).getDay()+"\t"+
             "积分为:"+arrayList.get(i).getScore());
           flag = false;
          }
         }
         if(flag){
          System.out.println("该会员号不存在,请在次输入要查询的会员号");
         }
        }
        System.out.println("输入任意值返回");
        if(in.next().equals("n")){
         continue;
        }
       }else if(c.equals("n")){
        break;
       }else{
        System.out.println("输入不正确,请重新输入");
       }
      }
     }else if(b == 2){
      ArrayList arrayList1 = new ArrayList();
      ArrayList arrayList2 = new ArrayList();
      arrayList1.add(new Commodity("adidas运动鞋",880.0));
      arrayList1.add(new Commodity("Kappa网球裙",333.5));
      arrayList1.add(new Commodity("网球拍\t",475.3));
      arrayList1.add(new Commodity("adidasT恤",198.8));
      arrayList1.add(new Commodity("Nike运动鞋",589.9));
      arrayList1.add(new Commodity("Kappa网球",80.7));
      arrayList1.add(new Commodity("KappaT恤",137.7));
      System.out.println("****************************************");
      System.out.println("请选择购买的商品编号:");
      for(int i =0;i
       System.out.println(i+1+":"+arrayList1.get(i).getName()+
            "(价格为:"+arrayList1.get(i).getMoney()+")");
      }
      System.out.println("****************************************");
      System.out.println("请输入会员号:");
      boolean flag =true;
      int m = 0;
      while(flag){
       String id = in.next();
       for(int e=0;e
        if(id.equals(arrayList.get(e).getId())){
         m = e;
         flag = false;
        }
       }
       if(flag){
        System.out.println("该会员号不存在,请再次输入要查询的会员号");
       }
      }
      
      double sum = 0;
      while(true){
       System.out.println("请输入商品编号:");
       int i = in.nextInt();
       double money = 0;
       switch(i){
       case 1:
         money = 880.0;
         break;
       case 2:
         money = 333.5;
         break;
       case 3:
         money = 475.3;
         break;
       case 4:
         money = 198.8;
         break;
       case 5:
         money = 589.9;
         break;
       case 6:
         money = 80.7;
         break;
       case 7:
         money = 137.7;
         break;
       }
       System.out.println("请输入数目:");
       int j = in.nextInt();
       double s = j*money;
       arrayList2.add(new String(arrayList1.get(i-1).getName()+"\t"+
           "¥"+arrayList1.get(i-1).getMoney()+"\t"+j+"\t"+
           "¥"+money*j));
       System.out.println("是否继续(y/n)");
       String y =in.next();
        if(y.equals("n")){
        System.out.println("**************消费清单***************");
        System.out.println("物品\t\t"+"单价\t"+"个数\t"+"金额");
        for(int x=0;x
         System.out.println(arrayList2.get(x));
        }
        sum += s;
        System.out.println("折扣:0.85\n"+"金额总支:"+"¥"+sum+"\n实际交费:"+"¥"+sum*0.85);
        System.out.println("本次获得积分:"+(int)(sum*0.85));
        arrayList.get(m).setScore((int)(sum*0.85)+arrayList.get(m).getScore());
        System.out.println("共有积分:"+arrayList.get(m).getScore());
        break;
       }
      }
      System.out.println("输入“n”返回");
      if(in.next().equals("n")){
       sum = 0;
       continue;
      }
     }else if(b == 3){
      System.out.println("我行我素购物管理系统->真情回馈");
      System.out.println("****************************************\n"+
           "\t\t1.幸运大放送\n"+
           "\t\t2.幸运抽奖\n"+
           "\t\t3.生日问候\n"+
           "****************************************\n"+
           "请选择,输入数字或输入“n”返回");
      int i = in.nextInt();
      if(i == 1){
       System.out.println("我行我素购物管理系统->真情回馈->幸运大放送");
       int max = 0;
       for(int t=0;t
        if(max < arrayList.get(t).getScore()){
         max = arrayList.get(t).getScore();
        }
       }
       int t = 0;
       for(t=0;t
        if(max == arrayList.get(t).getScore()){
         break;
        }
       }
       System.out.println("具有最高分的会员是:\n"+"会员号\t"+"生日\t"+"积分\n"+
            arrayList.get(t).getId()+"\t"+
            arrayList.get(t).getYear()+"-"+
            arrayList.get(t).getMonth()+"-"+
            arrayList.get(t).getDay()+"\t"+
            arrayList.get(t).getScore()+"\n"+
            "恭喜!获得的礼品是:一个价值¥12000的苹果笔记本电脑一台\n"+
            "输入“n”返回");
       if(in.next().equals("n")){
        continue;
       }
      }if(i == 2){
       System.out.println("我行我素购物管理系统->真情回馈->幸运抽奖\n"+
            "请输入会员号");
       boolean flag =true;
       while(flag){
        String id = in.next();
        for(int i1=0;i1
         if(id.equals(arrayList.get(i1).getId())){
          System.out.println("会员"+arrayList.get(i1).getId()+"开始抽奖");
          int random = (int)(Math.random()*100+1);
          if(random>=1 && random<10){
           System.out.println("恭喜会员"+arrayList.get(i1).getId()+"得到iphone5一台");
          }else if(random>=10 && random<50){
           System.out.println("恭喜会员"+arrayList.get(i1).getId()+"得到手机链一条");
          }else if(random>=50 && random<55){
           System.out.println("恭喜会员"+arrayList.get(i1).getId()+"得到lenovo超极本一台");
          }else{
           System.out.println("恭喜会员"+arrayList.get(i1).getId()+"得到罗技键鼠一套");
          }
          flag = false;
         }
        }
        if(flag){
         System.out.println("该会员号不存在,请在次输入要查询的会员号");
        }
       }
      }if(i == 3){
       System.out.println("我行我素购物管理系统->真情回馈->生日问候");
       System.out.println("请输入今天的月份:");
       String month = in.next();
       System.out.println("请输入今天几号:");
       String day = in.next();
       for(i=0;i
        if(month.equals(arrayList.get(i).getMonth()) && day.equals(arrayList.get(i).getDay())){
         System.out.println("祝会员"+arrayList.get(i).getId()+"生日快乐");
        }
       }
      }
     }else if(b == 4){
      word = "n";
      break;
     }else{
      System.out.println("输入不正确,请重新输入");
     }
    }
    if(word.equals("n")){
     continue;
    }
    break;
   }else if(a == 2){
    while(true){
     System.out.println("请输入用户名:");
     String name = in.next();
     System.out.println("请输入密码:");
     String password = in.next();
     if(name.equals(admin.getName()) && password.equals(admin.getPassword())){
      System.out.println("请输入新密码:");
      admin.setPassword(in.next());
      System.out.println("密码修改成功");
      System.out.println("输入n返回");
      if(in.next().equals("n")){
       break;
      }
     }else{
      admin.setPassword(password);
      System.out.println("用户名或密码输入错误,请重新输入");
     }
    }
   }else if(a == 3){
    break;
   }else{
    System.out.println("输入错误,请重新输入");
   }
  }
 }
}

 

 

更多信息可以参见同学富晓磊的博客:http://blog.sina.com.cn/u/1798827371

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值