-
-
Save CalvinRodo/2965910 to your computer and use it in GitHub Desktop.
is this done correctly?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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