Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2012 04:01
Show Gist options
  • Save anonymous/2963751 to your computer and use it in GitHub Desktop.
Save anonymous/2963751 to your computer and use it in GitHub Desktop.
is this done correctly?
public void calculateCost() {
switch (charRoom) {
case 'p':
case 'P':
type = "Private";
cost = privateRoom;
medication *= 2;
cost *= noOfDays;
medication *= noOfDays;
telephone *= noOfDays;
television *= noOfDays;
total = television + telephone + medication + cost;
break;
case 's':
case 'S':
type = "Semi-Private";
cost = semiPrivateRoom;
telephone -= telephone;
cost *= noOfDays;
medication *= noOfDays;
television *= noOfDays;
total = television + telephone + medication + cost;
break;
case 'w':
case 'W':
type = "Ward";
cost = ward;
telephone -= telephone;
television -= television;
medication /= 2;
medication *= noOfDays;
cost *= noOfDays;
total = television + telephone + medication + cost;
break;
default:
type = "Unknown";
break;
}
}
public String toString() {
if (type.equals("Unknown"))
return "Room is Unknown";
else
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