General Intent

In the first phase of the Grocery Express Project, you were required to provide design artifacts to describe your approach to structuring the classes, attributes, operations, methods and relationships needed to simulate the problem. Now, you are required to provide a lightweight implementation of the system in Java that reflects your design.

You are required to demonstrate fundamental separation of classes in your source code indicative of a reasonable design. This means that your source code should show some indication of being divided up into classes, files, etc. that match your design.

And don't panic if you realize that your original design had flaws while working on this assignment - this is common for "agile styles" of development. Make sure that your implementation works per these requirements and specifications and note your earlier design oversights with some brief comments in your code. Youre also being asked to provide improved design artifacts based on your revised and improved understanding of the problem space, and especially in light of the problem requirement changes included in this document.

We provide some examples of the expected input and output for a few test cases. You must provide the actual Java source code. We must also be able to recompile your application from your source code as part of the evaluation process.

Problem Scenario

Your requirements for the Grocery Express Project are continued here. Any requirements from the earlier assignments are carried over here unless explicitly modified and/or otherwise cancelled. If you feel that there are any conflicts between any of the earlier requirements and the more recent requirements, then please seek clarification immediately. In general, though, the newer requirements will take precedence.

This assignment involves implementing some of the core architecture and functional capabilities for the Grocery Express Project that you designed in the earlier assignments. Your system must implement the following functionality:

  • Create stores and allow them to offer items for purchase.
  • Create drones that can be used by stores to deliver orders.
  • Create pilots who can be hired by stores and assigned to fly the drones.
  • Create customers who can start orders and request items on those orders.
  • Allow orders to be eventually purchased or cancelled by customers.
  • Display various reports of the system's information (e.g., stores, customers, etc.) to view the systems state and verify that the operations are working correctly.

The instructions below will provide more details about the specific functions, including input and output formats, that your system will need to implement. Your system does not have to provide a Graphical User Interface. At this point, we will evaluate your system based on the text-based output and the structure of the source code. You'll have ample opportunity to develop a more advanced interface during the group project.

Input/Output & Command Formatting Requirements

We will test your program at this point using a relatively simple, text-based Command Line Interface (CLI) approach. The commands that we will use are listed below and your system is expected to follow the syntax of the commands as listed. Your program should accept input from a basic command (Terminal) interface - please don't use any windows, third-party text-input libraries, etc.

Welcome to the Grocery Express Delivery Service!

The following commands demonstrate a solid use case that exercises all the required functions with some sample data (corresponding to test_case0.txt). We have also provided "starter code" that highlights the required syntax for the functions to include parameters positions and data types (all Strings or Integers). The code we've provided generates the welcome header and handles the stop command to cease execution of the loop. Otherwise, you must generate the code to handle all the remaining commands to change and display information about the state of the system.

[1] > make_store,kroger,33000
OK:change_completed

The make_store command must create a store with the provided name that can be used to sell items to customers, along with the store's initial revenue. The name of the store must be unique. The "OK" message is used for commands that change the system state to acknowledge that it completed successfully. And the [] numbers are simply being used here to identify required functions - they are not required for the systems output.

[2] > display_stores
name:kroger,revenue:33000
OK:display_completed

The display_stores command must display the information about the all the stores that have been created. Note that the "OK" message here is for commands that display information about the system state.

When displaying any information, the system must display the information in ascending alphabetical order based on the identifying values used. For example, if we created three stores with the names "whole_foods", kroger and publix, then the associated records must be displayed in the order kroger, followed by publix, then followed by whole_foods. This applies to all the display commands listed here and below. This is important to ensure that your program's output matches the sequence of the expected test results consistently.

There are various ways to achieve the ordering, and you are welcome to use whichever one works best for you. One suggestion: while hash maps are generally well known to most programmers and software developers, you should also investigate Java's implementation of tree maps.

[3] > sell_item,kroger,pot_roast,5
OK:change_completed
> sell_item,kroger,cheesecake,4
OK:change_completed

The sell_item command must add the item provided to the "catalog" of items available to be requested and purchased from the store. The name of the store must be valid, and the item name must be unique within that store. The weight of the item will also be provided.

[4] > display_items,kroger
cheesecake,4
pot_roast,5
OK:display_completed

The display_items command must display the information about all the items that are available for request/purchase at a specific store. The information must be displayed in ascending alphabetical order of the item names.

[5] > make_pilot,ffig8,Finneas,Fig,888-888-8888,890-12-3456,panam_10,33
OK:change_completed

The make_pilot command must create a pilot who could fly a drone later to support grocery deliveries. The pilot must have an account (i.e., ffig8) that is unique among all pilots, along with a first and last name, phone number, tax ID, license ID and experience level measured in terms of the number of deliveries completed successfully. The license ID (i.e., panam_10) must also be unique among all pilots.

[6] > display_pilots
name:Finneas_Fig,phone:888-888-8888,taxID:890-12-3456,licenseID:panam_10,
experience:33
OK:display_completed

The display_pilots command must display the information about all the pilots who've been introduced in the system. The information must be displayed in ascending alphabetical order of the pilots identifiers (e.g., ffig8).

[7] > make_drone,kroger,1,40,3
OK:change_completed

The make_drone command must create a drone that can be used to deliver groceries to the appropriate customer when an order has been purchased. The drone's identifier (i.e., 1) must be unique for the drones at that store. Drones will also have a weight capacity and a measure of the number of deliveries that the drone can make before needing refueling.

[8] > display_drones,kroger
droneID:1,total_cap:40,num_orders:0,remaining_cap:40,trips_left:3
OK:display_completed

The display_drones command must display the information about all the drones that can be used to deliver grocery orders for a specific store. Note that a drone will not include the name of the pilot unless one has been assigned. The information must be displayed in ascending alphabetical order of the drone's identifiers (e.g., 1). A drones identifier is not limited to integers - it could be a string.

[9] > fly_drone,kroger,1,ffig8
OK:change_completed

The command must assign the given pilot (i.e., ffig8) to take control of the given drone (i.e., drone 1 at the store kroger). A pilot can only control one drone at a time, and a drone can only be controlled by one pilot at a time.

> display_drones,kroger
droneID:1,total_cap:40,num_orders:0,remaining_cap:40,trips_left:3,flown_by
:Finneas_Fig
OK:display_completed

The display_drones command has already been introduced. Note that the listing now includes the name of the pilot who was recently assigned (i.e., flown_by:Finneas_Fig).

[10] > make_customer,aapple2,Alana,Apple,222-222-2222,4,100
OK:change_completed

The make_customer command must create a customer who can start orders, request items and eventually purchase (or cancel) those orders. The customer must have an account (i.e., aapple2) that is unique among all customers, along with a first and last name, phone number, customer rating and credits (i.e., money used to purchase items).

[11] > display_customers
name:Alana_Apple,phone:222-222-2222,rating:4,credit:100
OK:display_completed

The display_customers command displays all the customers who have been introduced in the system. The information must be displayed in ascending alphabetical order of the customer's identifiers (e.g., aapple2).

[12] > start_order,kroger,purchaseA,1,aapple2
OK:change_completed
> start_order,kroger,purchaseB,1,aapple2
OK:change_completed

The start_order command must create the initial "stub" for an order at a given store for a given customer (i.e., aapple2). The identifier (i.e., purchaseA) must be unique for all orders at that store. Also, the drone and customer identifiers must be valid.

[13] > display_orders,kroger
orderID:purchaseA
orderID:purchaseB
OK:display_completed

The display_orders command must display information about all the orders at a given store. The orders should also display all the items that have been requested for each order. The information must be displayed in ascending alphabetical order of the store order's identifiers (e.g., purchaseA).

[14] > request_item,kroger,purchaseA,pot_roast,3,9
OK:change_completed
> request_item,kroger,purchaseB,pot_roast,4,4
OK:change_completed

The request_item command must add an item to the designated order. The quantity and unit price (i.e., 3 and 9, respectively) will be decided at the time the command is entered. An item can only be added to an order once. More importantly, the item must be added to the order if - and only if the following conditions are true: (1) the customer has enough remaining credits to afford the new item; and, (2) the drone has enough remaining capacity to carry the new item as part of its payload.

> display_orders,kroger
orderID:purchaseA
item_name:pot_roast,total_quantity:3,total_cost:27,total_weight:15
orderID:purchaseB
item_name:pot_roast,total_quantity:4,total_cost:16,total_weight:20
OK:display_completed

The command has already been introduced. Note that the display now includes information about all the items listed under each order.

[15] > purchase_order,kroger,purchaseA
OK:change_completed

The command must complete the purchase of the order and the delivery of the groceries to the appropriate customer. The purchase must be completed if - and only if the drone delivering the order has a pilot assigned and enough fuel to complete the delivery. There are five significant changes to the system's state that must be enacted to successfully complete the purchase: (1) the cost of the order must be deducted from the customers credits; (2) the cost of the order must be added to the stores revenue; (3) the number of remaining deliveries (i.e., fuel) for the drone must be reduced by one; (4) the pilots experience (i.e., number of successful deliveries) must be increased by one; and, (5) the order must otherwise be removed from the system.

> display_customers
name:Alana_Apple,phone:222-222-2222,rating:4,credit:73
OK:display_completed
> display_stores
name:kroger,revenue:33027
OK:display_completed
> display_orders,kroger
orderID:purchaseB
item_name:pot_roast,total_quantity:4,total_cost:16,total_weight:20
OK:display_completed
> display_pilots
name:Finneas_Fig,phone:888-888-8888,taxID:890-12-3456,licenseID:panam_10,
experience:34
OK:display_completed

These commands have been displayed to demonstrate the changes to the system's state after the delivery of the purchaseA order. The $27 of credits for the purchaseA order have been transferred from aapple2 to kroger, and the drone fuel and pilot experience have been updated.

[16] > cancel_order,kroger,purchaseB
OK:change_completed

The cancel_order command simply removes the order from the system without otherwise changing the system' state.

> display_customers
name:Alana_Apple,phone:222-222-2222,rating:4,credit:73
OK:display_completed
> display_stores
name:kroger,revenue:33027
OK:display_completed
> display_orders,kroger
OK:display_completed
> display_pilots
name:Finneas_Fig,phone:888-888-8888,taxID:890-12-
3456,licenseID:panam_10,experience:34
OK:display_completed

These commands have already been introduced and are displayed here just to confirm that the system's state has not been modified after the purchaseB order was cancelled.

[17] > stop
stop acknowledged
simulation terminated

This command simply causes the (otherwise infinite) interactive loop to halt.

Additional commands to create, update, delete and display elements of the system will be added during later phases of the project.

Sample Code

We've included some sample Java source "starter code" that provides the command loop for terminal-based data input. You are also welcomed to use portions of the code in your own solution and use of the provided starter code is 100% optional: you are NOT required/obligated to use this code. We've also provided some test cases, though you are also welcome (and encouraged) to develop your own tests as well. You are permitted to share your test cases with fellow students, but you are not permitted to share code and/or specific directions on the code or designs need to pass the cases.

If you would like to take a closer look at the starter code, then the best way might be to create a new Java project with blank Main and DeliveryService files, and then import the provided content. Similarly, you can compile and experiment with the code and create a new JAR file as well. We've also provided an initial copy of the JAR file that can be executed in two ways:

[1] Interactively (Enter the commands manually as highlighted):

$ java -jar drone_delivery.jar
Welcome to the Grocery Express Delivery Service!
make_store,kroger,33000
> make_store,kroger,33000
OK:change_completed
display_stores
> display_stores
name:kroger,revenue:33000
OK:display_completed
...
stop
> stop
stop acknowledged
simulation terminated
$

[2] Scripted (Recommended: Enter the commands via a text file as highlighted):

$ java -jar drone_delivery.jar < test_case_0.txt
Welcome to the Grocery Express Delivery Service!
> make_store,kroger,33000
OK:change_completed
> display_stores
name:kroger,revenue:33000
OK:display_completed
...
> stop
stop acknowledged
simulation terminated
$

Also, the test cases that we will use for this phase of the project will be fundamentally correct and consistent and will not include any errors like duplicate references (e.g., attempting to make two stores with the same name), invalid references (e.g., referring to non-existent stores or customers), or other (logical) constraints with respect to the problem/scenario description.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.