Skip to content

Instantly share code, notes, and snippets.

@CalvinRodo
Forked from anonymous/class.java
Created June 21, 2012 14:01
Show Gist options
  • Save CalvinRodo/2965910 to your computer and use it in GitHub Desktop.
Save CalvinRodo/2965910 to your computer and use it in GitHub Desktop.
is this done correctly?
Public void CalculatePrivateRoom(){
type = "Private";
cost = privateRoom;
medication *= 2;
cost *= noOfDays;
medication *= noOfDays;
telephone *= noOfDays;
television *= noOfDays;
total = television + telephone + medication + cost;
}
Private void CalculateSemiPrivateRoom(){
type = "Semi-Private";
cost = semiPrivateRoom;
telephone -= telephone;
cost *= noOfDays;
medication *= noOfDays;
television *= noOfDays;
total = television + telephone + medication + cost;
}
Private void CalculateWard(){
type = "Ward";
cost = ward;
telephone -= telephone;
television -= television;
medication /= 2;
medication *= noOfDays;
cost *= noOfDays;
total = television + telephone + medication + cost;
}
public void calculateCost(char charRoom) {
switch (charRoom) {
case 'p':
case 'P':
CalculatePrivateRoom();
break;
case 's':
case 'S':
CalculateSemiPrivateRoom();
break;
case 'w':
case 'W':
CalculateWard();
break;
default:
type = "Unknown";
break;
}
}
public String toString() {
if (type.equals("Unknown"))
{
return "Room is Unknown";
}
return "patient: " + name + "\n" + "Patient id: " + generator + "\n"
+ "The type of room you will stay in is: " + type + "\n"
+ "medication: " + nf.format(medication) + "\n" + "Telephone: "
+ nf.format(telephone) + "\n" + "Television: "
+ nf.format(television) + "\n\n" + "yout total is: "
+ nf.format(total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment