I need an example of a type of multifiled program and this is the closet\'s one
ID: 653860 • Letter: I
Question
I need an example of a type of multifiled program and this is the closet's one I could find to this description. Produce a psuedocode.
Problem statement:
Patient Bill:
You are to write a program that computes a patients bill for a hospital stay. The different components of the program are
1.The PatientAccount class
2.The Surgery class
3.The Pharmacy class
4.The main program
A.The PatientAccount class will keep a total of the patients charges. It will also keep track of the number of days spent in the hospital. The group must decide on the hospitals daily rate.
B.The Surgery class will have stored within it the charges for at least five types of surgery. It can update the charges variable of the PatientAccount class.
C.The Pharmacy class will have stored within it the price of at least five types of medication. It can update the charges variable of the PatientAccount class.
D.The student who designs the main program will design a menu that allows the user to enter a type of surgery and a type of medication, and check the patient out of the hospital. When the patient checks out, the total charges should be displayed.
E.You need to writer constructors and destructors, get functions (to retrieve appropriate attributes) and set functions (to set attribute values) for each class
The parameters and return types of each function and class member function should be decided in advance (during the analysis and design phase).
Think about what attributes to include in each class
Think of useful member functions for each class
The program will be best implemented as a multi-file program
Explanation / Answer
public class Patient
{
//Attributes: Object characteristics
private String name;
private int iDNumber;
private int age;
private String gender;
public Patient()
{
name = "none";
iDNumber = 0;
age = 0;
gender = "none";
}
public Patient(String n, int i, int a, String g)
{
name = n;
iDNumber = i;
age = a;
gender = g;
}
//Methods: object behavior, mutator method
public void setName(String n)
{
name = n;
}
//accessor methods
public String getName()
{
return name;
}
//Methods: object behavior, mutator method
public void setIdNumber(int i)
{
iDNumber = i;
}
//accessor methods
public int getiDNumber()
{
return iDNumber;
}
//Methods: object behavior, mutator method
public void setAge(int a)
{
age = a;
}
//accessor methods
public int getAge()
{
return age;
}
//Methods: object behavior, mutator method
public void setGender(String g)
{
gender = g;
}
//accessor methods
public String getGender()
{
return gender;
}
}
=======================================================
And this is my test... it doesnt seem to work properly and I dont know why :(
public class PatientTest
{
//this is an array of strings
public static void main(String [] args){
Patient p1 = new Patient("Joe Bloggs", 4125, 45, "Male");
Patient p2 = new Patient();
// new set methods to overwrite the old ones on patient 2
System.out.println("Name:"+ p2.getName());
System.out.println("iDNumber:"+ p2.getiDNumber());
System.out.println("Age:"+ p2.getAge());
System.out.println("Gender:"+ p2.getGender());
p2.setName("Larry");
p2.setIdNumber(12345);
p2.setAge(25);
p2.setGender("male");
//gets code from patient and gives values
System.out.println("Name:"+ p1.getName());
System.out.println("iDNumber:"+ p1.getiDNumber());
System.out.println("Age:"+ p1.getAge());
System.out.println("Gender:"+ p1.getGender());
//this is default code here which has no values in patient
System.out.println("Name:"+ p2.getName());
System.out.println("iDNumber:"+ p2.getiDNumber());
System.out.println("Age:"+ p2.getAge());
System.out.println("Gender:"+ p2.getGender());
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.