构造函数练习,求代码及注释
答案:1 悬赏:60
解决时间 2021-02-14 09:37
- 提问者网友:白柏唇蜜
- 2021-02-14 04:29
构造函数练习,求代码及注释
最佳答案
- 二级知识专家网友:浪者不回头
- 2021-02-14 05:37
wait a sec
public class Customer
{
//姓名、年龄、邮政编码、联系电话等信息
String name;
int age;
int postcode;
int phone;
public Customer(String _name,int _age,int _postcode,int _phone)
{
name=_name;
age=_age;
postcode=_postcode;
phone=_phone;
}
void Customer_out_age()
{
System.out.println("客户年龄为20岁");
}
void Customer_out_information()
{
System.out.println("客户姓名为:"+name+"年龄为:"+age+"邮政编码为:"+postcode+"联系电话为:"+phone);
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
Customer c1=new Customer("张三",17,11,13989999);
Customer c2=new Customer("李四",16,12,13999999);
c1.Customer_out_age();
c1.Customer_out_information();
c2.Customer_out_age();
c2.Customer_out_information();
}
}
public class Customer
{
//姓名、年龄、邮政编码、联系电话等信息
String name;
int age;
int postcode;
int phone;
public Customer(String _name,int _age,int _postcode,int _phone)
{
name=_name;
age=_age;
postcode=_postcode;
phone=_phone;
}
void Customer_out_age()
{
System.out.println("客户年龄为20岁");
}
void Customer_out_information()
{
System.out.println("客户姓名为:"+name+"年龄为:"+age+"邮政编码为:"+postcode+"联系电话为:"+phone);
}
public static void main(String[] args)
{
// TODO Auto-generated method stub
Customer c1=new Customer("张三",17,11,13989999);
Customer c2=new Customer("李四",16,12,13999999);
c1.Customer_out_age();
c1.Customer_out_information();
c2.Customer_out_age();
c2.Customer_out_information();
}
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯