Campervan租赁系统
在这项任务中,您将实施一个原型系统,可以作为Campervan租赁系统的“后端”。客户可以制作,更改和删除campervan预订。露营车可以是手动或自动。车辆必须被拿起并在同一车库下车。每个预订都有一个身份证号码,用于一个或多个露营者(手动和/或自动),由开始日期和结束日期确定一段时间(假设2017年是所有日期的年份,日期格式为HH MMM DD)。预订请求被全部授予或完全被系统拒绝;没有预订部分填写。
评估将基于您的程序的设计以及正确性。您应至少提交一个用于程序设计的UML类图,即不是随后从代码生成的。
所有输入都将是以下格式的一系列行,另外,一行注释(以'#'开头)可以出现在行尾。您的程序应该能够处理和丢弃这些注释(这包括只包含注释的整行)。
位置<depot> <name> <type>
#指定<depot>具有带有<type>的<name>的campervan
请求<id> <hour1> <month1> <date1> <hour2> <month2> <date2> <num1> <type1> [<num2> <type2>]
#预订请求<id>从<type1>类型的<num1>车辆的<hour1> <month1> <date1>到<hour2> <month2> <date2>等。
更改<id> <hour1> <month1> <date1> <hour2> <month2> <date2> <num1> <type1> [<num2> <type2>]
#将预订<id>从<hour1> <month1> <date1>到<hour2> <month2> <date2>与<type1>类型的<num1>车辆等。
取消<id>
#取消预订<id>(如果存在)并释放车辆
打印<depot>
打印<depot>中所有车辆的记录
在发出任何命令之前,所有的露营者将被宣布。为了消除任何歧义,预订请求和更改如下所述:仓库被检查(按照输入文件中出现的顺序),在每个仓库内,检查车辆(再次按照输入文件中的定义)确定车辆是否在所要求的时间段内可用,如果是,该车辆被分配给预订。请注意,每个仓库的车辆都会被声明在一个区块中(参见样品输入),并且可以使用来自多个仓库的车辆来完成请求。露营车有一个独一无二的名字,必须至少有1小时的预订相同的campervan预订。预订或更改的输出应按照输入文件开头的声明顺序列出分配给预订的车辆(参见下面的示例)。每个预订和更改请求都可以询问一次给定类型的车辆一次(例如,不包括两个单独的自动车数)。对于打印,按照车辆申报的顺序输出指定仓库的所有车辆的预订,然后按照时间(小时内的时间:分钟格式HH:MM,三个字母格式的日期和两位数字)输出预订,每次预订一次线。
在默认包中创建所有Java源文件。调用您的主要Java文件VanRentalSystem.java。将名称作为参数传递的文件的输入从调用java VanRentalSystem的main方法读取并输出到System.out。对于机器标记,输出将被重定向到将与预期输出进行比较的文本文件(因此不要打印出额外的空格等),并记得关闭输入文件。为了简单起见,每个仓库名称将只是一个字。您可以假设预订ID是唯一的。以标准三字母格式打印出月份,并使用24小时时钟数小时。如果预订请求无法实现,打印出拒绝的预订,对于无法进行的更改,更改被拒绝以及取消不能进行的取消,取消拒绝。
要从文本文件(其名称应作为命令行参数传递给java,例如java VanRentalSystem input.txt)读取输入,请使用以下代码:
Scanner sc = null;
try
{
sc = new Scanner(new FileReader(args [0])); #args [0]是第一个命令行参数
}
catch(FileNotFoundException e){}
finally
{
if(sc!= null)sc.close();
}
sample Input(示例输入)
以下示例为输入格式以及含义.
Location CBD(车库地点) Wicked(车的名字) Automatic(自动档)
# Location CBD has Wicked campervan with automatic transmission
Location CBD Zeppelin Automatic
# Location CBD has Zeppelin campervan with automatic transmission
Location CBD Floyd Automatic
# Location CBD has Floyd campervan with automatic transmission
Location Penrith Queen Manual
# Location Penrith has Queen campervan with manual transmission
Location Cremorne Ramones Automatic
# Location Cremorne has Ramones campervan with automatic transmission
Location Cremorne Nirvana Automatic
# Location Cremorne has Nirvana campervan with automatic transmission
Location Sutherland Purple Manual
# Location Sutherland has Purple campervan with manual transmission
Location Sutherland Hendrix Manual
# Location Sutherland has Hendrix campervan with manual transmission
Location Sutherland Eagle Manual
# Location Sutherland has Eagle campervan with manual transmission
# Test whether campervans can be rented from different depots when one depot exhausts its allocation of vehicles
Request 1 23 Mar 25 12 Mar 26 3 Automatic 1 Manual
# Request 1 is for 3 Automatic and 1 Manual campervan from 23:00 on Mar 25 to 12:00 on Mar 26
# Assign Wicked, Zeppelin, Floyd of CBD and Queen of Penrith
# Output Booking 1 CBD Wicked, Zeppelin, Floyd; Penrith Queen
# Test whether vans already booked are skipped and the next available van in order of declaration is assigned to booking
Request 2 12 Mar 24 15 Mar 27 1 Manual
# Request 2 is for 1 Manual campervan from 12:00 on Mar 24 to 15:00 on Mar 27
# Assign Purple of Sutherland since Queen of Penrith is booked
# Output Booking 2 Sutherland Purple
Request 3 13 Mar 26 21 Mar 26 2 Automatic 2 Manual
# Request 3 is for 2 Automatic and 2 Manual vans from 13:00 on Mar 26 to 21:00 on Mar 26
# Assign Wicked and Zeppelin of CBD, Queen of Penrith and Hendrix of Sutherland
# Output Booking 3 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Hendrix
Change 1 23 Mar 27 23 Mar 29 3 Manual 2 Automatic
# Change booking 1 to 3 Manual and 2 Automatic vans from 23:00 on Mar 27 to 23:00 on Mar 29
# Deassign Wicked, Zeppelin, Floyd of CBD and Queen of Penrith, and assign Queen of Penrith,
# Purple and Hendrix of Sutherland and Wicked and Zeppelin of CBD
# Output Change 1 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Purple, Hendrix
Request 4 11 Mar 25 09 Mar 26 1 Automatic
# Request 4 is for 1 Automatic campervan from 11:00 on Mar 25 to 9:00 on Mar 26
# Assign Wicked of CBD
# Output Booking 4 CBD Wicked
Cancel 3
# Cancel booking 3
# Deassign Wicked and Zeppelin of CBD, Queen of Penrith and Hendrix of Sutherland
# Output Cancel 3
Request 5 11 Mar 26 09 Mar 26 4 Manual
# Request 5 is for 4 Manual campervans from 11:00 on Mar 26 to 9:00 on Mar 26
# Request cannot be fulfilled
# Output Booking rejected
Print CBD
# Print out bookings of all campervans at CBD, in order of campervan declarations, then date/time;
# for each booking giving the start and end time and date in the format described above
Sample Output(示例输出)
The output corresponding to the above input is as follows:
Booking 1(1号订单) CBD Wicked, Zeppelin, Floyd; Penrith Queen
Booking 2 Sutherland Purple
Booking 3 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Hendrix
Change 1 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Purple, Hendrix
Booking 4 CBD Wicked
Cancel 3
Booking rejected
CBD Wicked 11:00 Mar 25 09:00 Mar 26
CBD Wicked 23:00 Mar 27 23:00 Mar 29
CBD Zeppelin 23:00 Mar 27 23:00 Mar 29
在这项任务中,您将实施一个原型系统,可以作为Campervan租赁系统的“后端”。客户可以制作,更改和删除campervan预订。露营车可以是手动或自动。车辆必须被拿起并在同一车库下车。每个预订都有一个身份证号码,用于一个或多个露营者(手动和/或自动),由开始日期和结束日期确定一段时间(假设2017年是所有日期的年份,日期格式为HH MMM DD)。预订请求被全部授予或完全被系统拒绝;没有预订部分填写。
评估将基于您的程序的设计以及正确性。您应至少提交一个用于程序设计的UML类图,即不是随后从代码生成的。
所有输入都将是以下格式的一系列行,另外,一行注释(以'#'开头)可以出现在行尾。您的程序应该能够处理和丢弃这些注释(这包括只包含注释的整行)。
位置<depot> <name> <type>
#指定<depot>具有带有<type>的<name>的campervan
请求<id> <hour1> <month1> <date1> <hour2> <month2> <date2> <num1> <type1> [<num2> <type2>]
#预订请求<id>从<type1>类型的<num1>车辆的<hour1> <month1> <date1>到<hour2> <month2> <date2>等。
更改<id> <hour1> <month1> <date1> <hour2> <month2> <date2> <num1> <type1> [<num2> <type2>]
#将预订<id>从<hour1> <month1> <date1>到<hour2> <month2> <date2>与<type1>类型的<num1>车辆等。
取消<id>
#取消预订<id>(如果存在)并释放车辆
打印<depot>
打印<depot>中所有车辆的记录
在发出任何命令之前,所有的露营者将被宣布。为了消除任何歧义,预订请求和更改如下所述:仓库被检查(按照输入文件中出现的顺序),在每个仓库内,检查车辆(再次按照输入文件中的定义)确定车辆是否在所要求的时间段内可用,如果是,该车辆被分配给预订。请注意,每个仓库的车辆都会被声明在一个区块中(参见样品输入),并且可以使用来自多个仓库的车辆来完成请求。露营车有一个独一无二的名字,必须至少有1小时的预订相同的campervan预订。预订或更改的输出应按照输入文件开头的声明顺序列出分配给预订的车辆(参见下面的示例)。每个预订和更改请求都可以询问一次给定类型的车辆一次(例如,不包括两个单独的自动车数)。对于打印,按照车辆申报的顺序输出指定仓库的所有车辆的预订,然后按照时间(小时内的时间:分钟格式HH:MM,三个字母格式的日期和两位数字)输出预订,每次预订一次线。
在默认包中创建所有Java源文件。调用您的主要Java文件VanRentalSystem.java。将名称作为参数传递的文件的输入从调用java VanRentalSystem的main方法读取并输出到System.out。对于机器标记,输出将被重定向到将与预期输出进行比较的文本文件(因此不要打印出额外的空格等),并记得关闭输入文件。为了简单起见,每个仓库名称将只是一个字。您可以假设预订ID是唯一的。以标准三字母格式打印出月份,并使用24小时时钟数小时。如果预订请求无法实现,打印出拒绝的预订,对于无法进行的更改,更改被拒绝以及取消不能进行的取消,取消拒绝。
要从文本文件(其名称应作为命令行参数传递给java,例如java VanRentalSystem input.txt)读取输入,请使用以下代码:
Scanner sc = null;
try
{
sc = new Scanner(new FileReader(args [0])); #args [0]是第一个命令行参数
}
catch(FileNotFoundException e){}
finally
{
if(sc!= null)sc.close();
}
sample Input(示例输入)
以下示例为输入格式以及含义.
Location CBD(车库地点) Wicked(车的名字) Automatic(自动档)
# Location CBD has Wicked campervan with automatic transmission
Location CBD Zeppelin Automatic
# Location CBD has Zeppelin campervan with automatic transmission
Location CBD Floyd Automatic
# Location CBD has Floyd campervan with automatic transmission
Location Penrith Queen Manual
# Location Penrith has Queen campervan with manual transmission
Location Cremorne Ramones Automatic
# Location Cremorne has Ramones campervan with automatic transmission
Location Cremorne Nirvana Automatic
# Location Cremorne has Nirvana campervan with automatic transmission
Location Sutherland Purple Manual
# Location Sutherland has Purple campervan with manual transmission
Location Sutherland Hendrix Manual
# Location Sutherland has Hendrix campervan with manual transmission
Location Sutherland Eagle Manual
# Location Sutherland has Eagle campervan with manual transmission
# Test whether campervans can be rented from different depots when one depot exhausts its allocation of vehicles
Request 1 23 Mar 25 12 Mar 26 3 Automatic 1 Manual
# Request 1 is for 3 Automatic and 1 Manual campervan from 23:00 on Mar 25 to 12:00 on Mar 26
# Assign Wicked, Zeppelin, Floyd of CBD and Queen of Penrith
# Output Booking 1 CBD Wicked, Zeppelin, Floyd; Penrith Queen
# Test whether vans already booked are skipped and the next available van in order of declaration is assigned to booking
Request 2 12 Mar 24 15 Mar 27 1 Manual
# Request 2 is for 1 Manual campervan from 12:00 on Mar 24 to 15:00 on Mar 27
# Assign Purple of Sutherland since Queen of Penrith is booked
# Output Booking 2 Sutherland Purple
Request 3 13 Mar 26 21 Mar 26 2 Automatic 2 Manual
# Request 3 is for 2 Automatic and 2 Manual vans from 13:00 on Mar 26 to 21:00 on Mar 26
# Assign Wicked and Zeppelin of CBD, Queen of Penrith and Hendrix of Sutherland
# Output Booking 3 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Hendrix
Change 1 23 Mar 27 23 Mar 29 3 Manual 2 Automatic
# Change booking 1 to 3 Manual and 2 Automatic vans from 23:00 on Mar 27 to 23:00 on Mar 29
# Deassign Wicked, Zeppelin, Floyd of CBD and Queen of Penrith, and assign Queen of Penrith,
# Purple and Hendrix of Sutherland and Wicked and Zeppelin of CBD
# Output Change 1 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Purple, Hendrix
Request 4 11 Mar 25 09 Mar 26 1 Automatic
# Request 4 is for 1 Automatic campervan from 11:00 on Mar 25 to 9:00 on Mar 26
# Assign Wicked of CBD
# Output Booking 4 CBD Wicked
Cancel 3
# Cancel booking 3
# Deassign Wicked and Zeppelin of CBD, Queen of Penrith and Hendrix of Sutherland
# Output Cancel 3
Request 5 11 Mar 26 09 Mar 26 4 Manual
# Request 5 is for 4 Manual campervans from 11:00 on Mar 26 to 9:00 on Mar 26
# Request cannot be fulfilled
# Output Booking rejected
Print CBD
# Print out bookings of all campervans at CBD, in order of campervan declarations, then date/time;
# for each booking giving the start and end time and date in the format described above
Sample Output(示例输出)
The output corresponding to the above input is as follows:
Booking 1(1号订单) CBD Wicked, Zeppelin, Floyd; Penrith Queen
Booking 2 Sutherland Purple
Booking 3 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Hendrix
Change 1 CBD Wicked, Zeppelin; Penrith Queen; Sutherland Purple, Hendrix
Booking 4 CBD Wicked
Cancel 3
Booking rejected
CBD Wicked 11:00 Mar 25 09:00 Mar 26
CBD Wicked 23:00 Mar 27 23:00 Mar 29
CBD Zeppelin 23:00 Mar 27 23:00 Mar 29