繁体   English   中英

"我如何使结果出现错误并表明没有约会?"

[英]How do I make the outcome come out false and show that there's no appointment?

所以这是代码,它工作正常。 我只是想知道如何写一个虚假的陈述,表明那天没有约会。 真实的陈述在底部,它表明存在。

import java.util.Scanner;

public class  AppointmentDemo{
    public static void main(String[] args) {
                Appointment[] appointment = new Appointment[5];
                appointment[0]= new Onetime(" Root Canal", 2017,12,26);
                appointment[1]= new Monthly(" Teeth cleaning", 2017,12,25);
                appointment[2]= new Daily(" Filling", 2017, 12, 26);
                appointment[3]= new Onetime(" Crowns", 2017,12,13);
                appointment[4]= new Monthly(" Dentures", 2017,12,15);

            Scanner keyboard = new Scanner(System.in);
            System.out.println("Please input the day of the appointment (1-31) ");
                int day = keyboard.nextInt();
                System.out.println("Please input the month of the appointment (1-12) ");
                int month = keyboard.nextInt();
                System.out.println("Please input the year of the appointment (2016-2022) ");
                int year = keyboard.nextInt();
            System.out.println(year + " "+ month+" " + day);
        
        for (int i =0; i <5; i++){
            if (appointment[i].occursOn(year, month, day)== true){
                System.out.println("You have a" + appointment[i].getDescription() + " appointment on: " + year  + " "+ month+ " " + day);
            
            }
        }


}
    
}```

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM