Programming Assignment 1 ALCOLWORTHS SUPERMARKETS solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Introduction

The objective of this assignment is to implement an object-oriented program using Java, to manage products
stored in depots of Alcolworths Supermarkets. Assignment 2 will be an extension of this assignment.
SENG1110 students – This assignment can be completed in pairs.
SENG6110 students – This assignment must be completed individually.
Before you start
Carefully read the specification below. Make sure you have all the information necessary to start writing the
program. If you are uncertain of something, do not make assumptions. Post your questions to the discussion
board forum named “assignment 1” and check it regularly.
Try to start the assignment as soon as possible. There is a document “HelpToStartAssign1” and some Java files
on Blackboard, which you can use as a starting point.
Specification
When run, the program will display a menu of actions to the user, including one that exits the program. Until
the user chooses to exit, the menu is displayed again after each action is completed.
The program will keep track of up to 2 depots, and each depot will be able to hold up to 3 products.
The program should have the following functionalities:
1. A user may add a depot.
The user will specify the depot’s name.
There should be an error message if the depot already exists, or if there are already 2 depots.
2. A user may remove a depot.
The user will specify the depot’s name.
There should be an error message if the depot does not exist.
3. A user may add a product to a depot.
Normally, the user will specify the product’s name, price, weight, and quantity in inventory, along with
the depot’s name (price, weight and quantity need to be positive, if not, the program will show a
message and ask the input again)
If, upon being given a name, there is a product in any depot with that name, the program should
indicate this. The user will then only be queried for a quantity and depot name. Other details will be
taken from the existing product.
eg: Product exists, with price $ and weight . Adding additional
items.
There should be an error message if the depot does not exist, or already holds 3 different products.
4. A user may remove one item of a product from a depot.
The user will specify a product name and a depot name.
There should be an error message if the product does not exist in the depot, or the depot doesn’t
exist.
Otherwise, the quantity in inventory will be reduced by 1. After that, if the quantity of the product in
inventory is zero, then the product should be removed from the depot. There should be output
indicating this.
eg: One item of Product removed from depot
5. A user may query for a list of depots.
There should be output, describing the depots.
Normally, there should be one line per depot.
eg: Depot has products
If there are no depots, the output should be one line.
eg: No depots exist
6. A user may query for a list of products in a depot.
The user will specify the depot’s name.
There should be an error message if the depot does not exist.
Otherwise, there should be output describing the products.
Normally, there should be one line per product.
eg: Product has price $, weight kg, and quantity
If there are no products, the output should be one line.
eg: No products in depot
7. A user may query about a product’s presence in the depots.
The user will specify the product’s name.
There should be an error message if the product doesn’t exist.
Otherwise, there should be one output line for each depot the product is in.
eg: Product is in depot with quantity
8. A user may query for the cumulative value of all products in a depot.
The user will specify the depot name.
There should be an error message if the depot doesn’t exist.
Otherwise, there should be output describing the cumulative value.
eg: Depot has cumulative product value $
As an example, let’s say there exists a depot D1 containing products P1 and P2. P1 has price $10 and
quantity 2. P2 has price $5 and quantity 100. The cumulative value of all products in D1 would be
10*2+5*100 = 520.
Product names and depot names will be converted to lowercase after input (so a product name “Lava lamp”
will be interpreted just like “LAVA LAMP”).
Program Requirements
The program should consist of 3 classes:
• Product – stores the following details about a group of product items.
◦ name – String – the name of the product.
◦ price – double – the price of the product. Must be positive.
◦ weight – double – the weight of the product, in kilograms. Must be positive.
◦ quantity – int – the number of product items. Must be positive.
• Depot – stores the following details about a depot.
◦ name – String – the name of the depot.
◦ product1, product2, product3 – up to 3 Product objects.
• Interface – provides the user interface.
◦ depot1, depot2 – up to 2 Depot objects.
All data fields of your classes should be private (this is imposed so that you apply the principles of
encapsulation).
Your classes will also need methods to provide the required functionalities. The only class which should have
a main method is Interface.java, which should create an instance of the class Interface, and call a method
run(), which will display the menu to the user. This class will be the only one that takes input from and sends
output to the user. It may do so using either TIO or GUI methods (your choice). A template is shown below.
public class Interface {
private void run(){
//…
}
public static void main(String[] args){
Interface infFace = new Interface();
intFace.run();
}
}
You must not use arrays in this assignment.
Marks will be awarded for layout (including visual aspects (variable names, indentation) and structural aspects
(variable scope, method usage)), documentation (comments), and the submission’s ability to perform as
specified. A more detailed marking schema will be made available on Blackboard.
What to submit
You should submit the .java files (Product.java, Depot.java, Interface.java) and an assignment cover sheet, in
a compressed .zip file, via the “Assignment 1” link on Blackboard. Do not include .class files in your submission.
Add the name of the student(s) on the top of each Java file submitted. If you are completing the assignment
as a group (only SENG1110 students), add both namesin each Java file AND submit 2 assignment cover sheets.
Extra work for SENG6110 students
You are required to implement the interface using GUI.
Furthermore, you are required to provide a UML class diagram of your program. Extra material, including
lecture slides and a video are available in Blackboard.
Late Penalty and adverse circumstances
Note that your mark will be reduced by 10% for each day (or part day) that the assignment is late. This applies
equally to week and weekend days. You are entitled to apply for special consideration if adverse circumstances
have had an impact on your performance in an assessment item. This includes applying for an extension of
time to complete an assessment item. See https://www.newcastle.edu.au/currentstudents/learning/assessments-and-exams/adverse-circumstances for more details.
Prof Regina Berretta
2019