package com.wxws.sms; public class Customer { int No; int integarl; } package com.wxws.sms; public class Customers { Customer[] customers = new Customer[100]; public void add(Customer cust){ for (int i = 0; i <customers.length; i++) { if (customers[i]==null) { customers[i]=cust; break; } } } public void show(){ System.out.println("会员列表*****"); for (int i = 0; i <customers.length; i++) { if (customers[i]!=null) { System.out.print(customers[i].No+"\t"+customers[i].integarl+"\t"); } } } } package com.wxws.sms; import java.util.Scanner; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner (System.in); Customer A = new Customer(); Customers B = new Customers(); System.out.print("请输入会员编号:"); A.No=in.nextInt(); System.out.print("请输入会员积分:"); A.integarl=in.nextInt(); B.add(A); B.show(); } }
java-第十四章-代参的方法(二)-实现MyShopping系统的添加会员功能
原创
©著作权归作者所有:来自51CTO博客作者Y幕徐的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
第十四章:内置对象
学习要点:1.Global 对象2.Math 对象
JavaScript js ViewUI Math 字符串