⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processsalestest.java

📁 网上购物系统,实现了一个具体的框架
💻 JAVA
字号:
package com.digitstore.process.test;

import com.digitstore.process.domain.Store;
import com.digitstore.process.domain.product.Item;
import com.digitstore.process.domain.product.ProductCatalog;
import com.digitstore.process.domain.product.ProductSpecification;
import com.digitstore.process.handler.ProcessHandler;
import com.digitstore.process.manageruser.Customer;
import com.digitstore.process.sale.Sale;
import com.digitstore.process.server.ProductServiceFactory;

public class ProcessSalesTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String s; //用于控制输出格式
		
		//新建一个商店
		
		Store store= ProductServiceFactory.getInstance().getStore();
		store.setName("数码商店");
		store.setAddress("北京昌平区北京邮电大学宏福校区");
		//声明一个销售过程控制器
		ProcessHandler procHandler = store.getProcHandler();
		System.out.println(store);
		
		//新建2个商品条目
		Item item1 = new Item();
		item1.setItemID("mtv2009");
		item1.setQuantity(100);
		item1.setSatus(true);
		s="ItemID:"+item1.getItemID()+"  "+"Quantity:"+item1.getQuantity()+" "+"Status:"+item1.getStatus();
		System.out.println(s);
		Item item2 = new Item();
		item2.setItemID("mtv3000");
		item2.setQuantity(300);
		item2.setSatus(true);
		s="ItemID:"+item2.getItemID()+" "+"Quantity:"+item2.getQuantity()+" "+"Status:"+item2.getStatus();
		System.out.println(s);
		//新建两个商品描述
		ProductSpecification prodSpec1 = new ProductSpecification();
		prodSpec1.setProudctID("mm3001");
		prodSpec1.setItem(item1);
		s = "ProdSpecID:"+prodSpec1.getProdSpecID()+" "+"ItemID:"+prodSpec1.getItem().getItemID();
		System.out.println(s);
		prodSpec1.setName("周杰伦");
		prodSpec1.setUnitCost(25.4);
		prodSpec1.setDescription("周杰伦最新专辑,快快来购买啊!");
		s = "Name:"+prodSpec1.getName()+" "+"Price:"+prodSpec1.getUnitCost()+"\n"+prodSpec1.getDescription();
		System.out.println(s);
		
		ProductSpecification prodSpec2 = new ProductSpecification();
		prodSpec2.setProudctID("mm3302");
		prodSpec2.setItem(item2);
		s = "ProdSpecID:"+prodSpec2.getProdSpecID()+" "+"ItemID:"+prodSpec2.getItem().getItemID();
		System.out.println(s);
		prodSpec2.setName("孙燕姿");
		prodSpec2.setUnitCost(43.8);
		prodSpec2.setDescription("孙燕姿最新专辑,快快来购买啊!");
		s = "Name:"+prodSpec2.getName()+" "+"Price:"+prodSpec2.getUnitCost()+"\n"+prodSpec2.getDescription();
		System.out.println(s);
		//新建商品分类条目
		ProductCatalog prodCata = ProductServiceFactory.getInstance().getProductCatalog();
		prodCata.addProdSpec(item1.getItemID(), prodSpec1);
		prodCata.addProdSpec(item2.getItemID(), prodSpec2);
		
		ProductSpecification prodSpec3 = prodCata.findProdSpec(item1.getItemID());
		System.out.println(prodSpec3);
		ProductSpecification prodSpec4 = prodCata.findProdSpec(item2.getItemID());
		System.out.println(prodSpec4);
			
		//新建2个顾客
		Customer customer1 = new Customer();
		customer1.setCustomerID("xyz2009");
		customer1.setName("宝宝");
		s = "CustomerID:"+customer1.getCustomerID()+"-"+"Name:"+customer1.getName();
		System.out.println(s);
		Customer customer2 = new Customer();
		customer2.setCustomerID("xyz3000");
		customer2.setName( "娃娃");
		s = "CustomerID:"+customer2.getCustomerID()+"-"+"Name:"+customer2.getName();
		System.out.println(s);
		
		//添加进入商店顾客列表
		store.addCustomer(customer1.getCustomerID(), customer1);
		store.addCustomer(customer2.getCustomerID(), customer2);
		
		//顾客1开始新的购物
		procHandler.makeNewSale(customer1.getCustomerID());
		procHandler.enterItem(item1.getItemID(), customer1.getCustomerID());
		procHandler.enterItem(item1.getItemID(), customer1.getCustomerID());
		procHandler.setQuantityByItem(item1.getItemID(), 45, customer1.getCustomerID());
		procHandler.enterItem(item2.getItemID(), customer1.getCustomerID());
		procHandler.setQuantityByItem(item2.getItemID(), 38, customer1.getCustomerID());
		//结束购物
		procHandler.endSale(customer1.getCustomerID());
		//查看购物情况
		Sale sale1 = procHandler.getSale(customer1.getCustomerID());
		//查看购买商品的总额
		double total = sale1.getTotal();
		System.out.println(total);
		//查看是否购物结束
		System.out.println(sale1.getIscompleted());
		
		
		//顾客2开始新的购物
		procHandler.makeNewSale(customer2.getCustomerID());
		procHandler.enterItem(item1.getItemID(), customer2.getCustomerID());
		procHandler.setQuantityByItem(item1.getItemID(), 45, customer2.getCustomerID());
		procHandler.enterItem(item2.getItemID(), customer2.getCustomerID());
		procHandler.setQuantityByItem(item2.getItemID(), 60, customer2.getCustomerID());
		//查看购物情况
		Sale sale2 = procHandler.getSale(customer2.getCustomerID());
		//查看购买商品的总额
		total = sale2.getTotal();
		System.out.println(total);
		//更改部分商品数量
		sale2.setQuntitySLI(item1.getItemID(), 10);
		//移除商品1
		sale2.removeSalesLineItem(item2.getItemID());
		//再次查看总价
		total = sale2.getTotal();
		System.out.println(total);
		//结束购物
		procHandler.endSale(customer2.getCustomerID());
		//查看是否购物结束
		System.out.println(sale2.getIscompleted());
		

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -