Sunday, 15 July 2012

java - how to change a char to a boolean? -



java - how to change a char to a boolean? -

my question how alter char boolean. illustration have 2 class

one patient class bleedinghistory method , info:

public class patient { private static string name; private static boolean bleedinghistory = true; private string answer; private double urealevel; private double prolevel; public patient() { string name = "unknown"; double urealevel = 0.0; double prolevel = 0.0; boolean bleedinghistory = false; } public patient (string inname, boolean inbleedinghistory) { if (name != "" || bleedinghistory == true) { name = inname; bleedinghistory = inbleedinghistory; } else { name = "unknown"; bleedinghistory = false; } prolevel = 0.0; urealevel = 0.0; } public boolean getbleedinghistory() { homecoming bleedinghistory; } public void setbleedinghistory(boolean inbleedinghistory) { bleedinghistory = inbleedinghistory; }

and part of class phone call patientcheck inquire user come in whether patient has history of bleeding:

system.out.print("does patient has history of bleeding(yes or no)?: "); char inbleedinghistory; { inbleedinghistory = sc.next().charat(0); if (inbleedinghistory != 'n' && inbleedinghistory != 'n' && inbleedinghistory != 'y' && inbleedinghistory != 'y') {system.out.println("invalid answer, please come in yes or no: "); sc.nextline(); } }while (inbleedinghistory != 'n' && inbleedinghistory != 'n' && inbleedinghistory != 'y' && inbleedinghistory != 'y'); pat1 = new patient (inname, inbleedinghistory);

i know patientcheck part history bleeding wrong can right it? thanks

pat1 = new patient(inname, (inbleedinghistory=='y' || inbleedinghistory=='y'));

java char boolean setter getter

No comments:

Post a Comment