1) 用private封装属性:编号、姓名、号码、类别(listid、name、num、listtype)
2) 设置要求1相关getter、setter方法(如getListId、setListId)
3) 设置相关构造方法
4) 添加修改姓名、号码、类别的方法(如editName)
5) 添加显示所有信息方法
快点,好的话加分
要代码,速度,半小时弄出200分
编写通讯录的简单JAVA类(AddList),要求如下
答案:3 悬赏:70 手机版
解决时间 2021-03-20 07:42
- 提问者网友:暗中人
- 2021-03-19 12:50
最佳答案
- 五星知识达人网友:春色三分
- 2021-03-19 13:26
package test;
public class AddList {
private int listId;
private String name;
private int num;
private String listType;
public AddList() {
}
public AddList(int listId, String name, int num, String listType) {
this.listId = listId;
this.name = name;
this.num = num;
this.listType = listType;
}
public int getListId() {
return listId;
}
public void setListId(int listId) {
this.listId = listId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getListType() {
return listType;
}
public void setListType(String listType) {
this.listType = listType;
}
public void editName(String name) {
this.name = name;
}
public void editListType(String listType) {
this.listType = listType;
}
public void editListId(int listId) {
this.listId = listId;
}
public void editNum(int num) {
this.num = num;
}
@Override
public String toString() {
return "AddList [listId=" + listId + ", name=" + name + ", num=" + num
+ ", listType=" + listType + "]";
}
}代码如上,希望能帮到你。
public class AddList {
private int listId;
private String name;
private int num;
private String listType;
public AddList() {
}
public AddList(int listId, String name, int num, String listType) {
this.listId = listId;
this.name = name;
this.num = num;
this.listType = listType;
}
public int getListId() {
return listId;
}
public void setListId(int listId) {
this.listId = listId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getListType() {
return listType;
}
public void setListType(String listType) {
this.listType = listType;
}
public void editName(String name) {
this.name = name;
}
public void editListType(String listType) {
this.listType = listType;
}
public void editListId(int listId) {
this.listId = listId;
}
public void editNum(int num) {
this.num = num;
}
@Override
public String toString() {
return "AddList [listId=" + listId + ", name=" + name + ", num=" + num
+ ", listType=" + listType + "]";
}
}代码如上,希望能帮到你。
全部回答
- 1楼网友:孤独的牧羊人
- 2021-03-19 15:21
public class LinkNote {
private int listId;
private String name;
private int num;
private String listtype;
public int getListId() {
return listId;
}
public void setListId(int listId) {
this.listId = listId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getListtype() {
return listtype;
}
public void setListtype(String listtype) {
this.listtype = listtype;
}
public LinkNote(int listId, String name, int num, String listtype) {
super();
this.listId = listId;
this.name = name;
this.num = num;
this.listtype = listtype;
}
public LinkNote() {
super();
}
private void editName(String name){
this.setName(name);
}
private void editNum(int num){
this.setNum(num);
}
private void editType(String type){
this.setListtype(type);
}
private void showAll(List<LinkNote> links){
for (int i = 0; i < links.size(); i++) {
System.out.println(links.get(i).name + ","
+ links.get(i).listId + ","
+ links.get(i).num + ","
+ links.get(i).listtype);
}
}
}
- 2楼网友:笑迎怀羞
- 2021-03-19 14:18
你好!
package test;
public class AddList {
private int listId;
private String name;
private int num;
private String listType;
public AddList() {
}
public AddList(int listId, String name, int num, String listType) {
this.listId = listId;
this.name = name;
this.num = num;
this.listType = listType;
}
public int getListId() {
return listId;
}
public void setListId(int listId) {
this.listId = listId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getListType() {
return listType;
}
public void setListType(String listType) {
this.listType = listType;
}
public void editName(String name) {
this.name = name;
}
public void editListType(String listType) {
this.listType = listType;
}
public void editListId(int listId) {
this.listId = listId;
}
public void editNum(int num) {
this.num = num;
}
@Override
public String toString() {
return "AddList [listId=" + listId + ", name=" + name + ", num=" + num
+ ", listType=" + listType + "]";
}
}代码如上,希望能帮到你。
仅代表个人观点,不喜勿喷,谢谢。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯