酒店裡提前預定的代碼怎麼寫 以及顧客的入住信息的代碼 屬於怎麼寫
大致是這樣的,如果僅僅只是java代碼寫個封裝類就可以了
```public class Clinet {
private String name;
private String time;
private String room;
private int manydays;
private int price;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public int getManydays() {
return manydays;
}
public void setManydays(int manydays) {
this.manydays = manydays;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
然後用另一個類往裡面存或者取
public class Main {
public static void main(String[] args) {
ArrayList<Clinet> array=new ArrayList<Clinet>();
//這裡添加數據;每個數據都有new一次Clinet類
Clinet clinet=new Clinet();
clinet.setManydays(1);
clinet.setName("name");
clinet.setPrice(20);
clinet.setRoom("room");
clinet.setTime("2月11日");
array.add(clinet);
//獲取的方法
for (int i = 0; i < array.size(); i++) {
array.get(i).getManydays();
array.get(i).getName();
array.get(i).getPrice();
array.get(i).getRoom();
array.get(i).getTime();
}
}
}