准备工具类
在实际开发中,公司都会提供相应的工具类和开发库,可以提高开发效率,程序员也需要能够看懂别人写的代码,并能够正确的调用
- 了解Utility类的使用
- 测试Utility类(具体代码放最后)
House类
public class House {
//编号 房主 电话 地址 月租 状态(未出租/已出租)
private int id;
private String name;
private String phone;
private String address;
private int rent;
private String state;
public House(int id, String name, String phone, String address, int rent, String state) {
this.id = id;
this.name = name;
this.phone = phone;
this.address = address;
this.rent = rent;
this.state = state;
}
@Override
public String toString() {
return id +
"\t" + name +
"\t" + phone +
"\t" + address +
"\t" + rent +
"\t" + state ;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getRent() {
return rent;
}
public void setRent(int rent) {
this.rent = rent;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
}
HouseView类
public class HouseView {
private boolean loop = true;
private char key = ' ';
public void mainMemu(){
do {
System.out.println("------------房屋出租系统------------");
System.out.println("\t\t\t1 新 增 房 源");
System.out.println("\t\t\t2 查 找 房 屋");
System.out.println("\t\t\t3 删 除 房 屋");
System.out.println("\t\t\t4 修 改 房 屋 信 息");
System.out.println("\t\t\t5 房 屋 列 表");
System.out.println("\t\t\t6 退 出");
System.out.println("请输入你的选择:");
key = Utility.readChar();
switch (key){
case '1':
System.out.println("新 增");
break;
case '2':
System.out.println("查 找");
break;
case '3':
System.out.println("删 除");
break;
case '4':
System.out.println("修 改");
break;
case '5':
System.out.println("房 屋 列 表");
break;
case '6':
System.out.println("退 出");
loop = false;
break;
}
}while (loop);
}
}
HouseService类
首先得有一个字符成员用来接收用户输入
标签:String,System,name,房屋出租,println,设计,public,out From: https://www.cnblogs.com/tigerWei/p/17933872.html