
熟悉面向对象思维
创建类
package com.google.demo;
public class Goods {
int id;
String name;
double price;
int buyNumber;
}
创建测试类
package com.google.demo;
import javax.xml.ws.soap.Addressing;
import java.util.Scanner;
public class ShopCarTest {
public static void main(String[] args) {
Goods[] showCar = new Goods[100];
while (true) {
System.out.println("请你选择一下命令进行操作");
System.out.println("添加商品到购物车:add");
System.out.println("查询购物车商品展示:query");
System.out.println("修改商品购买数量:update");
System.out.println("结算购买商品的金额:pay");
System.out.println("退出界面:quit");
Scanner scanner = new Scanner(System.in);
System.out.println("请您输入命令:");
String command = scanner.next();
switch (command)