小芳便利店 源代码 java写的 ackage account; import junit.framework.TestCase; public class AccountTest extends TestCase { private Account AccountA; private Account AccountB; public AccountTest(String name) { super(name); } public void setUp(){ AccountA=new Account("notyy",100); AccountB=new Account("bricks",200); } public static void main(String args[]) { junit.textui.TestRunner.run(AccountTest.class); } public void testAccount(){ AccountA=new Account("notyy",100); AccountB=new Account("bricks",200); //assertEquals("notyy",AccountA.Owner); //assertEquals(100,AccountA.Balance,2); //assertEquals("bricks",AccountB.Owner); //assertEquals(200,AccountB.Balance,2); assertEquals("notyy",AccountA.getOwner()); } public void testCredit(){ AccountA=new Account("notyy",100); AccountB=new Account("bricks",200); AccountA.credit(100); //100+100=200 assertEquals(200,AccountA.getBalance(),2); AccountB.credit(150); //200+150=350 assertEquals(350,AccountB.getBalance(),2); } public void testDiscount(){ AccountA=new Account("notyy",100); AccountB=new Account("bricks",200); AccountA.discount(50); //100-50=50 assertEquals(50.00,AccountA.getBalance(),2); AccountB.discount(120); //200-120=80 assertEquals(80,AccountB.getBalance(),2); } public void testTransfer(){ AccountA.transfer(AccountB,80.00); //100-80=20 //200+80=280 assertEquals(20.00,AccountA.getBalance(),2); assertEquals(280.00,AccountB.getBalance(),2); } }
2022-11-15 08:18:48 9KB 便利店 源代码 java
1
小芳便利店的Goods类写的JUNIT测试代码。
2022-11-09 07:55:22 531B 小芳 JUNIT测试
1
版本要求: 1.程序体现面向对象的编程思想; 2.要求能够灵活添加新物品,并向用户提供多次购买一次性结帐的功能; 提示:可用以下三个类解决该问题 1.货物类(Goods):一个商品,包含了名称,价格信息 2.购物篮类(Basket):一个购物篮,包含了已经选择的东西 3. Store:小芳便利店 主程序 -static final Goods[] GOODS //所有商品 -static Basket basket //存放选中商品的购物篮 -static final String MESSAGE_HEADER //菜单顶部 -static final String MESSAGE_FOOTER //菜单底部 -static void exit() //打印消息退出整个程序 -static void checkOut() //买单,打印所有已经选择的商品 -static void invalidInput() //当输入错误的时候,打印消息 -static void addGoods(int choice) //添加选中的商品到购物篮 -static void printMenu() //打印菜单 +static void main(String args[]) //程序入口
2021-12-31 00:14:57 8KB 小芳便利店
1
程序体现面向对象的编程思想; 要求能够灵活添加新物品,并向用户提供多次购买一次性结帐的功能; 提示:可用以下三个类解决该问题 货物类(Goods):一个商品,包含了名称,价格信息
2021-10-28 20:13:16 3KB store
1
版本要求: 1. 程序体现面向对象的编程思想; 2. 要求能够灵活添加新物品,并向用户提供多次购买一次性结帐的功能; 提示:可用以下三个类解决该问题 1.货物类(Goods):一个商品,包含了名称,价格信息 Goods -String name -float price +Goods(String _name,float _price) +void setName(String _name) +String getName() +void setPrice(float _price) +float getPrice() 2.购物篮类(Basket):一个购物篮,包含了已经选择的东西 Basket -Vector goodsList +void addGoods(Goods goods) +Vector getAllGoods() +boolean isEmpty() +void clear() +float getTotalPrice() 3.Store:小芳便利店 主程序 Store -static final Goods[] GOODS //所有商品 -static Basket basket //存放选中商品的购物篮 -static final String MESSAGE_HEADER //菜单顶部 -static final String MESSAGE_FOOTER //菜单底部 -static void exit() //打印消息退出整个程序 -static void checkOut() //买单,打印所有已经选择的商品 -static void invalidInput() //当输入错误的时候,打印消息 -static void addGoods(int choice) //添加选中的商品到购物篮 -static void printMenu() //打印菜单 +static void main(String args[]) //程序入口 以下是对该程序的界面要求: 如果你选择了1(选择2、3、4、5、6类似): 之后你还可以继续选择其他的物品,在你确认购买完毕后,你可以选择9结帐: 按任意键后,你可以开始继续新一轮的购物。 以下是在购物过程中输入错误的反馈:
1
利用JAVA实现小芳便利店的货物销售,分次买,统一结账。
2019-12-21 19:50:26 3KB 小芳便利店
1