1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| package ProductOrder; import java.io.*; import java.util.*;
public class TestProduct {
public static void main(String[] args) throws IOException { // TODO Auto-generated method stub String str1,str2,str3; double dou1 = 0; Product pro1 = new Product("001", "Apple", 3.99); Product pro2 = new Product("002", "Banana", 5.99); Product pro3 = new Product("003", "Canyon", 21.99); Product pro4 = new Product("004", "Dove", 6.99); Product pro5 = new Product("004", "Eggs", 10.99); OrderItem bill1 = new OrderItem(pro1, 5); OrderItem bill2 = new OrderItem(pro1, 20); OrderItem bill3 = new OrderItem(pro2, 25); OrderItem bill4 = new OrderItem(pro5, 3); OrderItem bill5 = new OrderItem(pro4, 7); OrderItem bill6 = new OrderItem(pro1, 0); OrderItem bill7 = new OrderItem(pro5, 999); OrderItem bill8 = new OrderItem(pro5, 12); OrderItem bill9 = new OrderItem(pro2, 2); OrderItem bill10 = new OrderItem(pro3, 100); Coffee cof1 = new Coffee("01","Cappuccino",15.2,"American","Cure","Sweet","Heavy","Small","Oval"); CoffeeBrewer ord1 = new CoffeeBrewer("001","SUNNY",169.99,"Abrasive","PrueWater",3); BufferedReader buf = null;//声明 BufferedReader 对象 buf = new BufferedReader(new InputStreamReader(System.in));//实例化 BufferedReader String str = null;//接收输入内容 System.out.print("请输入新建Product,以“,”分开:"); str = buf.readLine();//读取输入内容 StringTokenizer st=new StringTokenizer(str,","); str1 = st.nextToken(); str2 = st.nextToken(); str3 = st.nextToken(); dou1 = Double.parseDouble(str3); Product pro6 = new Product(str1,str2,dou1); if(pro4.equals(pro5)) { System.out.println("Yes!"); } else { System.out.println("No!"); } System.out.println(bill10); System.out.println(cof1); System.out.println(pro6); System.out.println(ord1.getPrice()); System.out.println(bill1.getQuantity()); System.out.println(bill2.getProduct().getDescription()); }
}
|