检查特定的时间值并输出剩余部分。

huangapple 未分类评论45阅读模式
英文:

Check a specific time-value and give out the rest

问题

以下是翻译好的内容:

这个问题很难找到一个合适的标题。下面的方法用于一个管理程序,它应该检查特定的航班是否空闲,如果是的话,应该打印出航班的描述。但是否可能还可以从何时到何时告诉航班空闲(航班只能租用一个小时,营业时间是从8:00到20:00)。所以如果一个航班预订在16:00点,意味着租用在17:00结束。我们可以检查这个,然后说,航班编号1在以下时间段是空闲的:8:00到16:00,然后从17:00到20:00?这个方法,我对它的理解不多,因为不知道如何以及什么叫什么。任何一点帮助都会很感激。

该方法:

public static void available(int[] flightQuantity, String[] name, String[] description) {
    for (int i = 0; i < flightQuantity.length; i++) {
        if (name[i] == null) {
            System.out.println("航班描述:" + description[i] + " 是空闲的");
        }
    }
}

可以预订/租用航班的方法:

public static void bookFlight(int[] flightQuantity, String[] description, int[] time, int index, String[] firstName, String[] lastName) throws ParseException {
    Scanner sc = new Scanner(System.in);
    String h = "";
    System.out.println("您想预订哪个航班(请输入其编号)");
    index = sc.nextInt();
    for (int i = 0; i < description.length; i++) {
        if (index == i) {
            System.out.println("请输入预订人的名字:");
            firstName[i] = sc.nextLine();
            sc.nextLine();
            System.out.println("请输入预订人的姓氏:");
            lastName[i] = sc.nextLine();
            System.out.println("预订的时间是:(hh:mm)");
            int time2 = sc.nextInt();
            time[i] += time2;
            while (time[i] > 8 || time[i] < 20) {
                System.out.println("请输入8点到20点之间的时间:");
                time[i] = sc.nextInt();
            }
            SimpleDateFormat ft = new SimpleDateFormat("hh:mm");
        }
    }
}
英文:

It was a bit hard to find a title for it. The following method is for a management program and it should check if a specific fly is free and if it is, it should print this out with the description of the flight. But Would it be possible to also tell from which to which time is the flight free (the flight can only be rented for one hour and their opening hours are from 8:00 to 20:00). So if a flight is reserved for 16:00 o'clock, means the renting ends at 17:00. Can we check this, and then say, the flight nr.1 is free from: 8:00 to 16:00 and then from 17:00 to 20:00? The method that should this, i couldn't do much with it, as not knowing how and what is called. Any small help is appreciated.

The method:

public static void avilable(int[] flightQuantity, String[] name, String[] description) {
            for (int i = 0; i &lt; flugAnzahl.length; i++) {
                if (vorname[i] == null) {
                    System.out.println(&quot;The flight with the description: &quot; + bezeichnung[i] + &quot; is free&quot;);
                }
            }

The method where a flight can be booked/rented:

public static void flugBuchen(int[] flugAnzahl, String[] bezeichnung, int[] zeit, int index, String[] vorname, String[] nachname) throws ParseException {
        Scanner sc = new Scanner(System.in);
        String h = &quot;&quot;;
        System.out.println(&quot;Welchen Flug m&#246;chten Sie buchen (Geben Sie bitte die Nummer dieses ein)&quot;);
        index = sc.nextInt();
        for (int i = 0; i &lt; bezeichnung.length; i++) {
            if (index == i) {
                System.out.println(&quot;Geben Sie den Vornamen dieser Person ein: &quot;);
                vorname[i] = sc.nextLine();
                sc.nextLine();
                System.out.println(&quot;Geben Sie den Nachnamen dieser Person ein: &quot;);
                nachname[i] = sc.nextLine();
                System.out.println(&quot;F&#252;r wann wird der Flug gebucht: (hh:mm)&quot;);
                int zeit2 = sc.nextInt();
                zeit[i] += zeit2;
                while (zeit[i] &gt; 8 || zeit[i] &lt; 20) {
                    System.out.println(&quot;Geben Sie eine Zeit zwischen 8 und 20 ein: &quot;);
                    zeit[i] = sc.nextInt();
                }
                SimpleDateFormat ft = new SimpleDateFormat(&quot;hh:mm&quot;);
            }
        }

    }

huangapple
  • 本文由 发表于 2020年5月5日 17:07:57
  • 转载请务必保留本文链接:https://java.coder-hub.com/61609565.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定