Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me code the following in JAVA Please read the task thoroughly, and include many COMMENTS so I can understand! Full points will be

Please help me code the following in JAVA

Please read the task thoroughly, and include many COMMENTS so I can understand!

Full points will be awarded, thanks in advance!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

BoatDriver class:

/*

* Driver for Boat Reservation system

* Reads input file and prints reservations to console

*/

public class BoatDriver {

public static void main(String[] args) {

ResManager manager = new ResManager();

try {

Scanner scanner = new Scanner(new FileInputStream("boatFile.txt"));

while (scanner.hasNext())

{

manager.addReservable(new Boat(scanner));

}

} catch (FileNotFoundException e) {

System.out.println("file not found");

System.exit(0);

}

System.out.println();

BoatReservation r1 = new BoatReservation(2, "Chen family");

r1.addBoatPreference("kayak");

r1.addBoatPreference("zodiak");

r1.addBoatPreference("canoe");

manager.makeReservation(r1);

BoatReservation r2 = new BoatReservation(8, "Singh party");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2 = new BoatReservation(8, "Kal");

r2.addBoatPreference("dinghy");

r2.addBoatPreference("yacht");

r2.addBoatPreference("rowboat");

manager.makeReservation(r2);

r2 = new BoatReservation(8, "Party9");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

r2 = new BoatReservation(2, "Newmans");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2 = new BoatReservation(3, "Party2");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2 = new BoatReservation(9, "Party5");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2 = new BoatReservation(1, "Party6");

r2.addBoatPreference("aircraft carrier");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

r2 = new BoatReservation(3, "Party3");

r2.addBoatPreference("speedboat");

r2.addBoatPreference("zodiak");

r2.addBoatPreference("submarine");

manager.makeReservation(r2);

// Force failure

r2 = new BoatReservation(3, "Unlucky party");

r2.addBoatPreference("zodiak");

manager.makeReservation(r2);

System.out.println(" reservations before sort by customer");

System.out.println(manager);

System.out.println(" reservations after sort by customer");

manager.sortReservations();

System.out.println(manager);

}

} RestaurantDriver class:

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.util.Scanner;

/*

* Driver for Restaurant Reservations

*/

public class RestaurantDriver {

public static void main(String[] args) {

ResManager manager = new ResManager();

try {

Scanner scanner = new Scanner(new FileInputStream("tableFile.txt"));

while (scanner.hasNext())

{

manager.addReservable(new Table(scanner));

}

} catch (FileNotFoundException e) {

System.out.println("file not found");

System.exit(0);

}

//manager.printItems(); // debugging code, prints list of Tables

RestaurantReservation r1 = new RestaurantReservation(2, 3, "Chen family");

manager.makeReservation(r1);

RestaurantReservation r2 = new RestaurantReservation(8, 4, "Singh party");

manager.makeReservation(r2);

r2 = new RestaurantReservation(8, 4, "Kal");

manager.makeReservation(r2);

r2 = new RestaurantReservation(8, 4, "business1");

manager.makeReservation(r2);

RestaurantReservation r3 = new RestaurantReservation(2, 2, "Newmans");

manager.makeReservation(r3);

r2 = new RestaurantReservation(11, 4, "TooBig");

manager.makeReservation(r2);

r2 = new RestaurantReservation(10, 4, "party5");

manager.makeReservation(r2);

r3 = new RestaurantReservation(10, 4, "party6");

manager.makeReservation(r3);

r3 = new RestaurantReservation(10, 4, "overflow");

manager.makeReservation(r3);

System.out.println("Listing of reservations:");

System.out.println(manager);

System.out.println(" Sorted reservations");

manager.sortReservations();

System.out.println(manager);

}

} boatFile.txt:

kayak

rowboat

submarine

yacht

speedboat

aircraft carrier

pedalboat

canoe

zodiak

dinghy

tableFile.txt:

table1 6

table2 2

table3 4

table4 4

table5 8

table6 8

table7 10

table8 10

table9 2

table10 4

table11 4

*The driver is provided with the code & does not need to be changed!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions

Question

explain the concept of strategy formulation

Answered: 1 week ago