色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

Java設(shè)置學(xué)生類和借書卡類

鄭雨菲1年前6瀏覽0評論

Java是一種面向?qū)ο蟮木幊陶Z言,通過定義不同的類來實現(xiàn)不同的功能。在學(xué)生管理系統(tǒng)中,我們需要定義學(xué)生類和借書卡類,來記錄學(xué)生的基本信息和借書卡的狀態(tài)。

public class Student {
private String name;
private int age;
private String gender;
private String id;
private String major;
// 構(gòu)造函數(shù)
public Student(String name, int age, String gender, String id, String major) {
this.name = name;
this.age = age;
this.gender = gender;
this.id = id;
this.major = major;
}
// getter 和 setter 方法
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 String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
}

上面的學(xué)生類定義了學(xué)生的基本信息,通過構(gòu)造函數(shù)和getter / setter 方法來實現(xiàn)對學(xué)生對象的初始化和訪問。

public class BorrowCard {
private int cardId;
private String borrowDate;
private int borrowTimes;
private double fine;
// 構(gòu)造函數(shù)
public BorrowCard(int cardId, String borrowDate, int borrowTimes, double fine) {
this.cardId = cardId;
this.borrowDate = borrowDate;
this.borrowTimes = borrowTimes;
this.fine = fine;
}
// getter 和 setter 方法
public int getCardId() {
return cardId;
}
public void setCardId(int cardId) {
this.cardId = cardId;
}
public String getBorrowDate() {
return borrowDate;
}
public void setBorrowDate(String borrowDate) {
this.borrowDate = borrowDate;
}
public int getBorrowTimes() {
return borrowTimes;
}
public void setBorrowTimes(int borrowTimes) {
this.borrowTimes = borrowTimes;
}
public double getFine() {
return fine;
}
public void setFine(double fine) {
this.fine = fine;
}
}

上面的借書卡類定義了借書卡的狀態(tài)信息,包括卡號、借書時間、借書次數(shù)、罰款金額。同樣通過構(gòu)造函數(shù)和getter / setter 方法來實現(xiàn)對借書卡對象的初始化和訪問。