Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Order class has private data for String customer name, String street address, String city, and integer number of refrigerators. It offers a default constructor,
The Order class has private data for String customer name, String street address, String city, and integer number of refrigerators. It offers a default constructor, parameterized constructor, accessors, and mutators. This source code file Orders.java is available for your use.
The Truck class with private data for String license number, String city, integer total number of refrigerators loaded, and a Java Stack of Order. The refrigerators are loaded into the truck in LIFO order, so the last order loaded is the first order delivered. It offers a default constructor, parameterized constructor, accessors, and mutators. The isFull method returns the full status of the truck. A truck has a limit of refrigerators. This source code file Truck.java is partially developed for your use.
Add a boolean addOrder that is passed an order. It adds the order to the truck's stack and returns true if successful and returns false if the order cannot be loaded. All the refrigerators for the order must fit onto the truck to be successful.
Input:
File TodayOrders.txt contains a number of orders. Each order has a customer name, street address, town, and number of refrigerators. It is not known how many orders are listed. All orders are going to one of three cities: Portland, Lewiston, or Bangor.
Processing:
Declare Truck objects, one going to Portland, one to Lewiston, and one to Bangor. Set the license number as desired. The trucks are initially empty.
Iterate over the data from the file and place each order into its truck. Since a truck can store only refrigerators, store orders that cannot be delivered on an ArrayList of Order.
Write a display method that is passed a Truck object and report the delivery schedule for that truck. Note the LIFO delivery schedule as the last order loaded into the truck is the first order unloaded. Report the pending orders. See sample output.
Sample Output:
tablePrders to Portland,,CustomerStreet Address,RefrigeratorsTing Variety, Raskall DrMasters Meats, Congress StHanley Nursing Home, Main Storders to Lewiston,,RefrigeratorsCustomerStreet Address,Frenchs Funeral Home, Illuson Way,Jetson Livery, State Way,Billiards Grocery, Broadway,Orders to Bangor,,CustomerStreet Address,Astro Insurance, Helsinki Way,Mainway Grocers, Sedwick RdBabcock Grocers, Hiddleton StLakeside Dermatology, Lakeview DrPending Orders,,Nanas Day Care,Portland,Carterfield Cafe,Bangor,
Grading Rubric:
The program is not accepted if the Stack class is not used.
The program is not accepted if class level variables are used in the main application.
The program is not accepted with use of break, continue, or goto statements to jump out of loops or use of infinite loops while true
The program is not accepted if it does not compile. Please make an appointment with the instructor for help as needed.
Input:
TodayOrders.txt contains a number of orders Each order has a customer name, street address, town, and number of refrigerators. It is not known how many orders are listed. All orders are going to one of three cities: Portland, Lewiston, or Bangor.
TodayOrders.txt Hanley Nursing Home
Main St
Portland
Billiards Grocery
Broadway
Lewiston
Lakeside Dermatology
Lakeview Dr
Bangor
Masters Meats
Congress St
Portland
Jetson Livery
State Way
Lewiston
Babcock Grocers
Hiddleton St
Bangor
French's Funeral Home
Illuson Way
Lewiston
Ting Variety
Raskall Dr
Portland
Mainway Grocers
Sedwick Rd
Bangor
Nana's Day Care
Fulsom Lane
Portland
Astro Insurance
Helsinki Way
Bangor
Carterfield Cafe
Elk Park
Bangor
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started