如何将char更改为

如何将char更改为

我的问题是如何将char更改为布尔值。例如我有2节课

一种是仅采用出血史方法和信息的患者课程:

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()
            {
                return bleedingHistory;

            }

            public void setBleedingHistory(boolean inBleedingHistory)
            {

                bleedingHistory = inBleedingHistory;
            }


另一个类调用PatientCheck,要求用户输入患者是否有出血史:

System.out.print("Does the patient has a history of bleeding(Yes or No)?: ");
        char inBleedingHistory;
        do
        {
            inBleedingHistory = sc.next().charAt(0);
            if (inBleedingHistory != 'n' && inBleedingHistory != 'N' && inBleedingHistory != 'y' && inBleedingHistory != 'Y')
            {System.out.println("Invalid answer, please enter YES or NO: ");

            sc.nextLine();
            }

        }while (inBleedingHistory != 'n' && inBleedingHistory != 'N' && inBleedingHistory != 'y' && inBleedingHistory != 'Y');

        pat1 = new Patient (inName, inBleedingHistory);


我知道病史检查的患者检查部分是错误的,但是我该怎么做才能纠正它?谢谢

最佳答案

pat1 = new Patient(inName, (inBleedingHistory=='y' || inBleedingHistory=='Y'));

10-01 03:19