用java语言定义一个客户要求类costomer,要求:
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用java语言定义一个客户要求类costomer,要求:相关的知识,希望对你有一定的参考价值。
1)id :long型,代表编号
name: string类对象,代表姓名
age:int型,代表年龄
sex:boolean型,代表性别(其中:true表示男,false表示女)
phone:string类对象,代表联系电话
2)顾客类customer的方法有:
(1)customer(long i,string n ,int a, boolean s, string p);
有参构造函数,分别初始化编号、姓名、年龄、性别和联系电话
(2)public string to string():以“姓名:联系电话”的形式作为方法的返回值
(3)getxx()方法:得到属性值的方法。其中xx表示类中的各属性名
(4)setxx(dd)方法:各属性值设置方法,其中:xx表示类中的各属性名
(5)void print()方法:输出顾客的全部信息
private long id;
private String name;
private int age;
private boolean sex;
private String phone;
public long getId()
return id;
public void setId(long id)
this.id = id;
public String getName()
return name;
public void setName(String name)
this.name = name;
public int getAge()
return age;
public void setAge(int age)
this.age = age;
public boolean isSex()
return sex;
public void setSex(boolean sex)
this.sex = sex;
public String getPhone()
return phone;
public void setPhone(String phone)
this.phone = phone;
public String toString()
return "[编号:" + id + ", 姓名:" + name + ", 年龄:" + age + ", 性别:" + sex
+ ", 联系电话:" + phone + "]";
public Costomer(long id, String name, int age, boolean sex, String phone)
this.id = id;
this.name = name;
this.age = age;
this.sex = sex;
this.phone = phone;
public void print()
System.out.println(toString());
本回答被提问者采纳 参考技术B public class Customer
private long id;
private String name;
private int age;
private boolean sex;
private String phone;
public Customer(long id, String name, int age, boolean sex, String phone)
super();
this.id = id;
this.name = name;
this.age = age;
this.sex = sex;
this.phone = phone;
public String toString()
return name + ": " +phone;
public void print()
System.out.println("Customer Info:\n"
+ "id: " + id
+ "name: " + name
+ "age: " + age
+ "sex: " + (sex ? "男" : "女")
+ "phone: " + phone);
public long getId()
return id;
public String getName()
return name;
public int getAge()
return age;
public boolean isSex()
return sex;
public String getPhone()
return phone;
public void setId(long id)
this.id = id;
public void setName(String name)
this.name = name;
public void setAge(int age)
this.age = age;
public void setSex(boolean sex)
this.sex = sex;
public void setPhone(String phone)
this.phone = phone;
英语user和costomer作为用户的区别是啥?
英语user和costomer作为用户的区别是什么?
答:
①user:用户;指产品的使用者。
②User:是指已购买完成并正在使用产品及相关服务的自然人或组织。
③customer意为顾客,可以“买”,但不需要“用”。
④customer是指已经完成购买或有购买产品或服务需求的人或组织。
另外,请注意customer的拼写。
供参考
以上是关于用java语言定义一个客户要求类costomer,要求:的主要内容,如果未能解决你的问题,请参考以下文章