算是最简单的吧
在平桥等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供网站制作、成都网站制作 网站设计制作按需搭建网站,公司网站建设,企业网站建设,成都品牌网站建设,成都全网营销推广,成都外贸网站建设公司,平桥网站建设费用合理。
package cn.job01;
import java.util.Scanner;
public class Lx07 {
public static void choice() {
System.out.println("登陆菜单 ");
System.out.println("1登陆系统");
System.out.println("2退出");
}
static void choice1() {
System.out.println("购物管理系统客户信息");
System.out.println("1显示所有客户信息");
System.out.println("2添加客户信息");
System.out.println("3修改客户信息");
System.out.println("4查询客户信息");
}
static void choice2() {
System.out.println("购物管理系统真情回馈");
System.out.println("1幸运大放送");
System.out.println("2幸运抽奖");
System.out.println("3生日问候");
}
public static void main(String[] args) {
choice();
Scanner input = new Scanner(System.in);
System.out.println("请输入1or2");
int num = input.nextInt();
switch (num) {
case 1:
System.out.println("主菜单");
System.out.println("1客户信息管理");
System.out.println("2购物结算");
System.out.println("3真情回馈");
System.out.println("4注销");
break;
}
System.out.println("选择输入数字");
int num1 = input.nextInt();
switch (num1) {
case 1:
choice1();
break;
case 2:
System.out.println("购物结算");
break;
case 3:
choice2();
break;
case 4:
choice();
break;
}
}
}
package cn.test.logan.day04;
import java.util.ArrayList;
/**
* 订单类
* 包含:订单ID、订单所属用户、订单所包含的商品、订单总金额、订单应付金额
* 500-1000 ------- 8.5折
* 1000-1500 ------- 8折
* 1500-2000 ------- 7折
* 2000以上 ------- 6.5折
* 如果是会员,那么可以基于以上折扣继续折扣
* 一般会员:9.5折
* 中级会员:9折
* 高级会员:8折
* @author QIN
*
*/
public class Order {undefined
// 订单ID
public String ordId;
// 订单所属用户
public User user;
// 订单所包含的商品(多个商品,使用ArrayList)
public ArrayList pds;
// 订单总金额
public float ordAllAmt;
// 订单应付金额
public float payAmt;
// 计算总金额的方法
public void setAllAmt() {undefined
float sum = 0;
for(int i=0;i
sum +=this.pds.get(i).price * this.pds.get(i).number;
}
this.ordAllAmt = sum;
}
// 计算实付金额
public void setPayAmt() {undefined
float tmp = this.ordAllAmt;
// 根据总金额进行折扣
if(this.ordAllAmt = 500 this.ordAllAmt
tmp = this.ordAllAmt * 0.85f;
}
if(this.ordAllAmt = 1000 this.ordAllAmt
tmp = this.ordAllAmt * 0.8f;
}
if(this.ordAllAmt = 1500 this.ordAllAmt
tmp = this.ordAllAmt * 0.7f;
}
if(this.ordAllAmt = 2000) {undefined
tmp = this.ordAllAmt * 0.65f;
}
// 根据会员等级折扣
if(user.CustLevel.equals("一般会员")) {undefined
tmp = tmp * 0.95f;
}
if(user.CustLevel.equals("中级会员")) {undefined
tmp = tmp * 0.9f;
}
if(user.CustLevel.equals("高级会员")) {undefined
tmp = tmp * 0.8f;
}
//计算结果赋值给对象上的payAmt变量
this.payAmt = tmp;
}
}
参考资料来源:百度贴吧CSDN博主「公子京」
/**
* 得到一个新的订单代码
* 说明,此函数还没有进行过多线程测试,更新数据库时未加锁
* @return 新的订单代码
*/
public String getOrderCode(){
//getParameter这个方法就是从数据库取2个参数的值 ORDER_CODE_DATE 和
//ORDER_CODE_NO是数据库字段名
BasParameters orderCodeDate = getParameter(ORDER_CODE_DATE);
BasParameters orderCodeNo = getParameter(ORDER_CODE_NO);
//当前日期
String currDate=new SimpleDateFormat("yyyyMMdd").format(new Date(System.currentTimeMillis()));
//每天的起始数
int orderNo = 100;
//表里存的日期和当前日期相同,顺序号累加
if (currDate.equals(orderCodeDate.getValue())){
orderCodeNo.setValue(""+(Integer.parseInt(orderCodeNo.getValue())+1));
orderNo = (Integer.parseInt(orderCodeNo.getValue()));
//save 就是保存ORDER_CODE_DATE 和 ORDER_CODE_NO当前值到数据库
save(orderCodeNo);
} else {
//表里存的日期和当前日期不同,顺序号重新开始,更新参数表的日期
orderCodeDate.setValue(currDate);
save(orderCodeDate);
orderCodeNo.setValue(orderNo);
save(orderCodeNo);
}
return currDate + new DecimalFormat("000000").format(orderNo);
}
import java.util.ArrayList;
public class Du {
public static void main(String[] args) throws Exception {
Seller seller = new Seller("My Store");
seller.addGoods("T-shirt", 200);
seller.addGoods("Pill", 100);
seller.addGoods("T-shirt", 100);
seller.addGoods("T-shirt", 50);
seller.addGoods("Pill", 50);
seller.addGoods("Hat", 100);
seller.printGoods();
Seller sell2 = new Seller("The Other Store");
sell2.addGoods("T-shirt", 200);
sell2.addGoods("Hat", 100);
sell2.sellGoods("T-shirt", 50);
sell2.addGoods("Hat", 100);
sell2.printGoods();
}
}
class Seller {
private String sellerName;
private int TotalTypeOfGoods;
private ArrayListString goodsNameList = new ArrayListString();
private ArrayListInteger goodsQuantityList = new ArrayListInteger();
public Seller(String sellerName) {
this.sellerName = sellerName;
}
public void addGoods(String goodName, int goodNum) {
int index = goodsNameList.indexOf(goodName);
if (index == -1) {
goodsNameList.add(goodName);
goodsQuantityList.add(new Integer(goodNum));
} else {
goodsQuantityList.set(index, goodsQuantityList.get(index)
.intValue()
+ goodNum);
}
TotalTypeOfGoods = goodsNameList.size();
}
public void sellGoods(String goodName, int goodNum) throws Exception {
if (TotalTypeOfGoods == 0) {
throw new Exception("No goods provided by the shop. Closed!");
}
int index = goodsNameList.indexOf(goodName);
if (index != -1) {
int qty = goodsQuantityList.get(index);
if (goodNum qty) {
throw new Exception("Insufficient goods in the shop. Sorry!");
}
goodsQuantityList.set(index, qty - goodNum);
}else{
throw new Exception("Our shop doesn't sell " + goodName);
}
}
public void printGoods() {
System.out.print("Seller :" + this.sellerName + "\t");
System.out.println("Totoal Types of Goods is :" + this.TotalTypeOfGoods);
for(int i = 0; i goodsNameList.size(); i++){
System.out.print("Goods Name: " + goodsNameList.get(i));
System.out.println("Remains: " + goodsQuantityList.get(i));
}
System.out.println();
}
}
-----------------testing
Seller :My Store Totoal Types of Goods is :3
Goods Name: T-shirtRemains: 350
Goods Name: PillRemains: 150
Goods Name: HatRemains: 100
Seller :The Other Store Totoal Types of Goods is :2
Goods Name: T-shirtRemains: 150
Goods Name: HatRemains: 200
售后响应及时
7×24小时客服热线数据备份
更安全、更高效、更稳定价格公道精准
项目经理精准报价不弄虚作假合作无风险
重合同讲信誉,无效全额退款