Assignment Course: Object-Oriented Programming Course ID: 503005 Subject: Manage Coffee Shop Module
Assignment Course: Object-Oriented Programming Course ID: 503005 Subject: Manage Coffee Shop Module
Assignment
Course: Object-Oriented Programming
Course ID: 503005
Subject: Manage coffee shop module
(Students please carefully read all the instructions before starting the
assignment)
I. Introduction
A coffee shop director needs to manage their products, customers, and orders. The staff of the shop
is divided into 2 types: the full-time staff and the part-time staff. In this assignment, students will
program some features to manage the business of the shop.
Features that students need to do:
- Read the staff list file.
- Based on the information from the file, perform queries based on requirements.
files, constructors, read and write files methods, and some empty methods. Students
will implement those empty methods and not edit predefined methods.
- SeasonalStaff class and FullTimeStaff class inherits from Staff class, Manager class
inherits FullTimeStaff class.
- Explanation of some of the properties and methods:
o Staff
▪ sID: staff ID.
▪ sName: staff name.
▪ Abstract method paySalary(int workingTime).
▪ toString(): return a string of the format: sID_sName
o Drink
▪ dName: drink name
▪ price: drink price
▪ toString(): return a string of the format: dName_ price
o Invoice
▪ invoiceID: invoice ID
▪ staffID: invoicing staff
Quang D.C – [email protected] | Object-Oriented Programming (503005) – 2022 4/13
Ton Duc Thang University
Faculty of Information Technology
▪ date: invoice creation date, save the string in the format dd/mm/yyyy
▪ toString(): return a string of the format: invoiceID_staffID_date
o InvoiceDetails
▪ invoiceID: invoice ID
▪ dName: drink name
▪ qty: quantity of the drink in the invoice
▪ toString(): return a string of the format: invoiceID_dName_qty
o StoreManagement
▪ staffs: staffs list
▪ workingTime: list of working times, this list is provided in the form of a list
of String.
▪ invoices: list of invoices, this list is provided in the form of a list of Invoice.
▪ invoiceDetails: list of invoices details, this list is provided in the form of a
list of InvoiceDetails.
▪ drinks: list of drinks, this list is provided in the form of a list of Drink.
▪ StoreManagement(String staffPath, String workingTimePath, String
invoicesPath, String detailsPath, String drinksPath): constructor, make
the call to the read file methods to read information to corresponding
attributes.
▪ getStaffs(), setStaffs(ArrayList<Staff> staffs): use to get Staff list and re-
assign Staff list. These two methods are for marking the assignment.
Students are not allowed to edit these methods.
▪ loadDrinks(String filePath), loadInvoices(String filePath),
loadInvoicesDetails(String filePath): methods that are used to read files
to lists. Students are not allowed to edit these methods.
▪ public static ArrayList<String> loadFile(String filePath): helper
method to read information from files. Students can use this method in their
implementation.
▪ displayStaffs(): print the staffs list to the command prompt.
▪ writeFile(String path, ArrayList<E> list): write to a file the provided list.
Students are not allowed to edit this method.
▪ writeFile(String path, E object): write a to file the provided object.
Students are not allowed to edit this method.
o FullTimeStaff – Official staff
▪ baseSalary: the base salary of the full-time staff
▪ bonusRate: the bonus rate of the official staff
▪ paySalary(int workedDays): return the salary, which will be described in
the parts below. With workedDays is the parameter of days that the staff
worked in the month.
- The input file named Staffs.txt contains the list of staff with each line corresponding to the
properties of one staff separated by the sign “,” in the following format:
o FullTimeStaff
Staff ID,Staff name,Base salary,Bonus rate
o Manager
Staff ID,Staff name,Base salary,Bonus rate,Allowance
o SeasonalStaff
Staff ID,Staff name,Hourly wage
o Invoice
Invoice ID,Staff ID,Invoice creation date
With staff ID the same as the staff ID in the staffs list, the invoice creation date is
stored in the format dd/mm/yyyy.
o InvoiceDetails
Invoice ID,Drink name ,Quantity
With Invoice ID the same as the invoice ID in the invoices list, drink name the
same as the drink name in the drinks list.
o Timekeeping: contains the timekeeping list of a month
Staff ID,Worked time
If the staff is a full-time one, the worked time is the worked days, if the staff is a
part-time one, the worked time is the worked hours.
- The output includes 5 files containing provided example output for the requirements:
o Req1.txt: the result of staff lists read from the file.
o Req2.txt: the result of five part-time staffs that have the highest salary in the month.
o Req3.txt: the result of staffs that have salary > 15,000,000.
o Req4.txt: the result of revenue in the first quarter.
o Req5.txt: the result of staff having the highest number of invoices created in June.
- Each line in the output Req1, Req2, Req3, and Req5 corresponds to one object with the
format toString() of the corresponding class.
Note:
- Students can add more data to the input file to test more cases but remember that the added
data must follow the format that is defined above.
- Students should carefully read the main method to correctly define the order to implement
classes and methods.
- Students can add code to the main method to test your implementation but make sure that
your program can run on the default provided by the main method.
- Students can add new methods to help with your implementations but make sure that the
student’s program can still run with the provided Test.java file.
- Students must not make an absolute path when defining methods related to reading files.
If students define an absolute path resulting in a cannot read a file during marking, it is
equivalent to a compile error.
- Students must not in any circumstances edit the class names and method names that are
defined initially (the naming always follows the class diagram above).
- Students do not make changes to files that are not required to be submitted.
VI. Requirements
Students must not add additional libraries, only use libraries in provided files.
Students implement your assignment in Java 11 or Java 8. Students must not use the data type var.
Students’ implementation will be scored in Java 11; students will be responsible for all the error
that happens if they were to use different Java versions.
1. REQUIREMENT 1 (2 POINTS)
Students implement the method public ArrayList<Staff> loadStaffs(String filePath) to read
staffs from file Staff.txt, create Staff objects, and import them to attribute staffs.
Students implement the method, the statement to call the constructor method of
StoreManagement in method main which will invoke to read file methods, if students correctly
implement the read file method for attribute staffs, then the predefined write file method will write
to the “Req1.txt”. Students compare this file to the expected output file Req1.txt in the output
folder.
Note: This is the method that students must be able to define to be eligible for scoring, if students
can’t read the file to be a list of Staff then the requirements below will not be scored.
The requirements below are depending on the list which is read from the files.
2. REQUIREMENT 2 (2 POINTS)
Implement method:
public ArrayList<SeasonalStaff> getTopFiveSeasonalStaffsHighSalary()
return a list of 05 part-time staffs with the highest salary in the list of staffs.
Students implement the method so that when invoking the main method, the correct output will
be written to the “Req2.txt”. Students compare this file to the expected output file Req2.txt in the
output folder.
3. REQUIREMENT 3 (2 POINTS)
Implement method:
public ArrayList<FullTimeStaff> getFullTimeStaffsHaveSalaryGreaterThan(int
lowerBound)
return a list of staff that has a higher salary than passed lowerBound. For example, provided
lowerBound is 15000000 then the returned list will contain staffs that have salaries > 15,000,000.
Note, the manager (Manager) is full-time staff.
Students implement the method so that when invoking the main method, the correct output will
be written to the “Req3.txt”. Students compare this file to the expected output file Req3.txt in the
output folder.
4. REQUIREMENT 4 (2 POINTS)
Implement method:
public double totalInQuarter(int quarter)
return the total revenue of the passing quarter. Knowing that the first quarter includes the months
1, 2, 3, the second quarter includes the months 4, 5, 6, and the same for the third and fourth quarters.
The total revenue is the total of invoices for months in that quarter. The total of one invoice is the
total cost of drinks in the invoice. The total cost of a drink is the price of that drink multiplied by
the quantity in the invoice.
Students implement the method so that when invoking the main method, the correct output will
be written to the “Req4.txt”. Students compare this file to the expected output file Req4.txt in the
output folder.
5. REQUIREMENT 5 (2 POINTS)
Implement method:
public Staff getStaffHighestBillInMonth(int month)
return the staff had the highest sum of the cost of the invoices in the month. The total cost of
invoices of staff in the month is calculated by adding the total of each invoice that staff has made
in the month.
Students implement the method so that when invoking the main method, the correct output will
be written to the “Req5.txt”. Students compare this file to the expected output file Req5.txt in the
output folder.
- All of the files ReqX.txt (X = {1,2,3,4,5}) are written at the same level as the source code
directory. For students that use IDE (Eclipse, Netbeans, …) make sure that the program
can be run with commands in command prompt, make sure that the program does not exist
inside a package, the position for written file ReqX.txt must be in the same level as the
source code directory.
- Correct structure of written file when running the program will follow this image:
- In case of wrong submission (wrong folder naming, not placing the files into the folder,
more files than required, …) then students will get 0 point.
- Correct file structure will be:
o Compressed file:
- If the compilation of students’ implementation results in an error, you will receive 0 point
for all requirements.
- All of your code will be checked for plagiarism. Any behaviors of copying code from
the Internet, copying your friend’s code, or allowing your friends to copy your code
if detected you will receive 0 point for the whole Process 2 point or not being able to
participate in the final exam.
- If students implementation have sign of copying code from the Internet or copying each
other, students will be call for a code interview to prove that the implementation is indeed
their.
- Submission deadline: 23h00 of May 25th, 2022
-- END --