Untitled
unknown
plain_text
7 months ago
1.5 kB
1
Indexable
Never
import java.util.Date; public class Inpatient { // Define private fields for each attribute private String name; private int age; private int hospitalNumber; private Date dateOfAdmission; private double roomRent; // Define a constructor that initializes all fields public Inpatient(String name, int age, int hospitalNumber, Date dateOfAdmission, double roomRent) { this.name = name; this.age = age; this.hospitalNumber = hospitalNumber; this.dateOfAdmission = dateOfAdmission; this.roomRent = roomRent; } // Define getter methods for each field public String getName() { return name; } public int getAge() { return age; code> public int getHospitalNumber() { return hospitalNumber; } public Date getDateOfAdmission() { return dateOfAdmission; } public double getRoomRent() { return roomRent; } // Define setter methods for each field (optional) public void setName(String name) { this.name = name; } public void setAge(int age) { this.age = age; } public void setHospitalNumber(int hospitalNumber) { this.hospitalNumber = hospitalNumber; } public void setDateOfAdmission(Date dateOfAdmission) { this.dateOfAdmission = dateOfAdmission; } public void setRoomRent(double roomRent) { this.roomRent = roomRent; } }
Leave a Comment