发布网友 发布时间:2024-10-18 04:34
共1个回答
热心网友 时间:2024-11-05 23:20
public class OrderDemo
{
public static void main(String[] args)
{
System.out.println("\n\t\t==========订单测试!==========\n");
init();
}//初始化!
private static void init()
{
//创建对象!
Order ord=new Order();
//打印默认值!
ord.get();
System.out.println("\n-----------------------------------------------------\n");
//创建商品数组并,赋值!
int x=1001,number[]={x++,x++,x++,x++,x++};
int y=24,money[]={y++,y++,y++,y++,y++,};
String[] arr={"苹果","桔子","菠萝","香蕉","蜜桃"};
ord.set(number,money,arr);
//赋完值在打印!
ord.get();
}
}
//订单!
class Order
{
private int[] number=new int[5];//订单号!
private int[] money=new int[5];//订单金额!
private String[] arr=new String[5];//商品数组!
void set(int[] number,int[] money,String[] arr)
{
this.number=number;
this.money=money;
this.arr=arr;
}
void get()
{
for (int i=0;i<arr.length ;i++ )
{
System.out.println("商品编号=>"+number[i]+"\t订单金额=>"+money[i]+"\t商品名称=>"+arr[i]);
}
}
}