CSC186 Group Project 2022
CSC186 Group Project 2022
PREPARED FOR:
NAME
Items Page
3.0 Objective 6
9.0 References 39
2
1.0 ORAGANIZATIONAL STRUCTURE
3
2.0 INTRODUCTION
Table 1
1 Services
2 Browse Products
Table 1.1
2 Diagnostic RM170
3 Inspection RM62
Extra RM10 Will be Charge For the Service’s Fee
4
Table 1.2
Product Num. Product Name Price
Table 1.3
COURIER Services Name Price
CODE
4 Skynet RM 5.00
5
By choosing the services, customer will be making an appointment with the
computer store employee to book the available time and date for faster
progress without needing to walk-in. The store also has the features of
browsing available products that were being sell by the store via the online
shopping system. Along with that, a small amount of tax will also be applied
at the end of the checkout which cost around RM0.09 for each item and
services selected. An amazing 9% discount would also be given to the
customer if their item’s quantity is over five. At the end, the program will
generate a receipt for the customer, and calculating the total daily revenue,
as well as updating the estimation revenue of the store.
3.0 OBJECTIVES
6
4.0 UML DIAGRAM
7
4.2 Use Case Diagram:
8
5.0 Input Data
INPUT 1: INPUT 2:
INPUT 3: INPUT 4:
INPUT 5: INPUT 6:
INPUT 7:
INPUT 8: INPUT 9:
9
INPUT 12: INPUT 13:
INPUT 16:
10
INPUT 21: INPUT 22:
INPUT 23:
INPUT 24:
11
6.0 Class Definition of Inheritance and Polymorphism
Super Class: 1:
import java.util.Random;
import java.util.Scanner;
//Create CLASSES
Scanner in = new Scanner(System.in);
Random rand = new Random();
public Customer(){
userName = "";
userPass = "";
oriCusID = 0;
totalItem = 0;
}
12
public void setCusID() {
int cusID;
cusID = rand.nextInt(100000);
oriCusID = cusID;
}
while(loginLoop == 1) {
System.out.println("\nSIGNING YOU IN :)");
System.out.println("Enter your username: ");
name = in.nextLine();
verifyLogin = true;
System.out.println("\nVerification Sucessful");
loginLoop = 0;
}
else {
verifyLogin = false;
System.out.println("\nVerification Failed. Your Username and Password Don't Match");
loginLoop =1;
}
}
return verifyLogin;
}
13
public void addToCart() {
countLoop++;
totalItem = countLoop;
}
2:
import java.util.Scanner;
public Services(){
super();
serviceChoose = 0;
productChoose = 0;
courierChoose = 0;
product_id = 0;
service_id = 0;
courier_id = 0;
productPrice = 0;
courierCharge = 0;
serviceCharge = 0;
appointment = "-";
courierName = "";
productName ="";
serviceName ="";
14
public Services(int sc, int pc, int cc, int p_id, int s_id, int c_id, double pP, double cC, double sC, String a, String cn, String
pn, String sn){
serviceChoose = sc;
productChoose = pc;
courierChoose = cc;
product_id = p_id;
service_id = s_id;
courier_id = c_id;
productPrice = pP;
courierCharge = cC;
serviceCharge = sC;
appointment = a;
courierName = cn;
productName = pn;
serviceName = sn;
}
//GETTTTTTERRs
public int getserviceChoose()
{
return serviceChoose;
}
15
public double getserviceCharge()
{
return serviceCharge;
}
System.out.println("\n\nINPUT: ");
courierChoose = in.nextInt();
if(courierChoose == 1){
if(productChoose == 1){
productName = "AMD Radeon R7 350 2GB";
product_id = 4428;
productPrice = 100.00;
}
else if(productChoose == 2){
productName ="Intel Xeon X5670 @2.9Ghz";
product_id = 1832;
productPrice = 90.00;
}
else if(productChoose == 3){
productName = "KaZe SODIMM DDR4 4GB 2400Mhz";
product_id = 3454;
productPrice = 80.00;
}
else if(productChoose == 5){
productName = "KaZe WGC2 Veno II Dual Mode Wireless Mouse";
product_id = 6789;
productPrice = 55.00;
}
else if(productChoose == 8){
productName = "USB Flash Drive 8GB";
product_id = 5523;
productPrice = 15.00;
}
else if(productChoose == 9){
productName = "KaZe 95mb/s 633x Micro SD Card";
product_id = 7284;
productPrice = 45.00;
}
else if(productChoose == 10){
productName = "KaZe SSD SATA III 2.5 Inch 128GB";
product_id = 3282;
productPrice = 69.00;
if(serviceChoose == 1){
serviceName = "Diagnostic";
serviceCharge = 170;
}
else if(serviceChoose == 2){
serviceName = "Inspection";
serviceCharge = 62;
18
//Processor methods for the Services 1
public void showServices()
{
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | SERVICES CODE | SERVICES NAME | PRICE | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Services 1 | DIAGNOSTIC | RM 170 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Services 2 | INSPECTION | RM 62 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | EXTRA RM 10 WILL BE CHARGE FOR THE SERVICE'S FEE
| ");
System.out.println(" +-----------------------------------------------------------------------------------------+ ");
System.out.println("\nINPUT: [Day/Month/Year]");
in.nextLine();
appointment = in.nextLine();
System.out.println("\n| YOUR NEWEST ENTERED APPOINTMENT DATE WILL BE SET AS THE LATEST ONE
|"); 19
return appointment;
}
public void resetValue(){
courierCharge = 0;
serviceCharge = 0;
productPrice = 0;
}
Subclass: 1:
import java.util.Scanner;
import javax.swing.JOptionPane;
// instance variables
private double total;
private double tax;
private double totalTax;
public Checkout(){
super();
total = 0;
totalTax = 0;
bankName = "";
bankUsername = "";
}
public Checkout(String UN, String UP, int CUS, int TL, double ttl, double tx, String bN, String buN){
super(UN,UP,CUS,TL);
total = ttl;
totalTax = tx;
bankName = bN;
bankUsername = buN;
}
20
//Accessor methods for the Checkout
public double gettotal(){
return total;
}
return totalTax;
}
return total;
}
while(mpLoop == 1){
System.out.println("\nDo you want to proceed with the payment?");
System.out.println(" YES | NO ");
String input5 = in.nextLine();
21
if(input5.equalsIgnoreCase("yes"))
{
JOptionPane.showMessageDialog(null,"YOU'LL BE DIRECTED TO THE BANK WEBSITE");
bankName = JOptionPane.showInputDialog("Please Enter Your Bank Name");
bankUsername = JOptionPane.showInputDialog("Please Enter Your Bank Account Username");
bankPass = JOptionPane.showInputDialog("Please Enter Your Bank Account Password");
System.out.println("\nPayment Successful!!\n");
makePayment = true;
mpLoop = 0;
}
else if(input5.equalsIgnoreCase("no"))
{
System.out.println("\nPayment Aborted!!");
makePayment = false;
mpLoop = 0;
}
else{
System.out.println("\nPLEASE ENTER CORRECTLY!!");
makePayment = false;
mpLoop = 1;
}
return makePayment;
}
2:
import java.util.Scanner;
//default constructor
public Admin(){
super();
diagStatus = "FALSE";
insStatus = "FALSE";
servCompStat = "FALSE";
servPrice = 0;
}
//normal constructor
public Admin(int sc, int pc, int cc, int p_id, int s_id, int c_id, double pP, double cC, double sC, String a, String cn, String
pn, String sn ,String ds,String is,String SC,double sp){
super(sc, pc, cc, p_id, s_id, c_id, pP, cC, sC, a, cn, pn, sn);
diagStatus = ds;
insStatus = is;
servCompStat = SC;
servPrice = sp;
}
22
public String getDiagStatus(){
return diagStatus;
}
System.out.println(" !!********************+*********************+***********************+*********
************************************************|");
System.out.println(" !! | | | |");
System.out.println(" !! | | | |");
System.out.println(" !! 15/07/2022 | 3454 | 574 | NEW STOCK IN 23 DAYS
|");
23
System.out.println(" !! | | | |");
System.out.println(" !!********************+*********************+***********************+*********
************************************************|");
System.out.println(" !! | | | |");
System.out.println(" !! | | | |");
System.out.println(" !! 15/07/2022 | 6789 | 8574 | NEW STOCK IN 83 DAYS
|");
System.out.println(" !! | | | |");
System.out.println(" !!********************+*********************+***********************+*********
************************************************|");
System.out.println(" !! | | | |");
System.out.println(" !! | | | |");
System.out.println(" !! 15/07/2022 | 9182 | 10574 | NEW STOCK IN 97
DAYS |");
System.out.println(" !! | | | |");
System.out.println("
+===================================================================================================
==========================+\n");
}
diagStatus = "TRUE";
servCompStat = "TRUE";
}
public void scheduleAppoint()
{
insStatus = "TRUE";
servCompStat = "TRUE";
24
3:
import javax.swing.JOptionPane;
import java.util.Random;
import java.text.DecimalFormat;
public StoreKeeper(){
super();
receiptID = 0;
itemQuantity = 0;
dailyIncome = 0;
monthlyIncome = 0;
storeName = "XenoTec Enterprise";
receiptDate = "18/07/2022";
}
public StoreKeeper(int sc, int pc, int cc, int p_id, int s_id, int c_id, double pP, double cC, double sC, String a, String cn, String pn, String
sn , String ds, String is, String SC, double sp,int RID, int IQ, double DI, double MI, String SN, String RD){
super(sc, pc, cc, p_id, s_id, c_id, pP, cC, sC, a, cn, pn, sn, ds, is, SC, sp);
receiptID = RID;
itemQuantity = IQ;
dailyIncome = DI;
monthlyIncome = MI;
storeName = SN;
receiptDate = RD;
}
25
public void setreceiptID() {
int repID;
repID = rand.nextInt(100000);
receiptID = repID;
}
double estimatedMonthlyIn;
estimatedMonthlyIn = day * amountDI;
monthlyIncome = estimatedMonthlyIn;
return monthlyIncome;
26
7.0 Class Application
Main
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;
double total_serv = 0;
double total_browse = 0;
//VARIABLES
String newCustomer;
String viewAccount = "yes";
String yes_loop = "yes";
String end_system = "no";
String main_loop = "yes";
String passOrfail_newHere = "yes";
String mainmenu_Loop = "yes";
String payment_loop = "yes";
double total_holder6 = 0;
double total_ultimate = 0;
double total_end_holder = 0;
total_tax = 0;
int MainMenu = 0;
//CLASS DECLARATION
Checkout checkout = new Checkout();
customerC[i] = new Checkout();
services[i] = new Services();
//ID GENERATED
customerC[i].setCusID();
27
while(passOrfail_newHere == "yes"){
//first question for user
System.out.println("If this is your first time signing in. \nPlease update your profile first!\n");
System.out.println("Are you new here? \n [ YES | NO ]");
//INPUT 1
System.out.println("Input: ");
newCustomer = in.nextLine();
//Method Declaration
customerC[i].verifyLogin();
if(viewAccount.equalsIgnoreCase("yes")) {
customerC[i].customerinfo();
}
else{
}
while(end_system.equalsIgnoreCase("no")) {
while(yes_loop.equalsIgnoreCase("yes")) {
if(yes_loop.equalsIgnoreCase("yes")) {
customerC[i].addToCart();
}
while(mainmenu_Loop == "yes"){
28
System.out.println("\n[MAIN MENU]");
System.out.println("\nPlease Choose The Available Options: ");
System.out.println("\n1. Services\n2. Browse Products");
System.out.println("\nYou will be needing to set an APPOINMENT if SERVICES is CHOSEN");
System.out.println("\n\nINPUT: ");
MainMenu = in.nextInt();
total_browse = 0;
total_serv = 0;
admin.resetServPrice();
//services[i].resetValue();
if(MainMenu == 1){
services[i].resetValue();
admin.resetScheduleAppoint();
admin.scheduleAppoint1();
services[i].showServices();
services[i].serviceChoose();
services[i].appointmentDate();
mainmenu_Loop = "false";
total_holder3 = 0;
admin.setServPrice();
}
else if(MainMenu == 2){
services[i].resetValue();
admin.resetScheduleAppoint();
admin.scheduleAppoint();
services[i].browseProduct();
services[i].productPrice();
total_holder3 = 0;
services[i].RequestCourier();
total_holder3 = services[i].getcourierCharge();
admin.resetServPrice();
mainmenu_Loop = "false";
}
else{
System.out.println("\nPLEASE ENTER CORRECTLY!!");
mainmenu_Loop = "yes";
}
total_holder4 = admin.getServPrice();
total_holder = services[i].getproductPrice();
total_holder2 = services[i].getserviceCharge();
29
total_serv = total_holder2 + total_holder4;
total_browse = total_holder + total_holder3;
System.out.println("\nTHE AMOUNT OF TOTAL BROWSE: RM"+total_browse);
System.out.println("THE AMOUNT OF TOTAL SERVICE: RM"+total_serv);
total_tax = checkout.calculateTotalTax(customerC[i].getItemInCart());
if(viewAccount.equalsIgnoreCase("yes")) {
customerC[i].customerinfo();
}
else{
}
System.out.println("Do you want to log out from the system? [ YES|NO ]");
end_system = in.nextLine();
if(end_system.equalsIgnoreCase("yes")) {
System.out.println("\nThank You and Come Again Next Time :D\n\n");
}
else {
}
//GENRATE RECEIPT ID
storekeeper.setreceiptID();
int amountI = customerC[i].getItemInCart();
30
double productPrice = services[i].getproductPrice();
double courierCharge = services[i].getcourierCharge();
double serviceCharge = services[i].getserviceCharge();
//CONSTRUCTOR
customerC[i] = new Checkout(name, password, userID, totalItem, totalC, taxC, bankName, bankUsername);
services[i] = new Services(serviceChoose, productChoose, courierChoose, product_id, service_id, courier_id, productPrice,
courierCharge, serviceCharge,appointment, courierName, productName, serviceName);
services[i] = new Admin(serviceChoose, productChoose, courierChoose, product_id, service_id, courier_id, productPrice,
courierCharge, serviceCharge,appointment, courierName, productName, serviceName, DiagStatus, InsStatus, servCompStat, servPrice);
services[i] = new StoreKeeper(serviceChoose, productChoose, courierChoose, product_id, service_id, courier_id, productPrice,
courierCharge, serviceCharge,appointment, courierName, productName, serviceName, DiagStatus, InsStatus, servCompStat,
servPrice,receiptID, itemQuantity, dailyIncome, monthlyIncome, storeName, receiptDate);
//CUSTOMER COUNTER
int customerCounter = 0;
//COPYING
Checkout obj = new Checkout();
StoreKeeper obj1 = new StoreKeeper();
31
System.out.println(" ...................... ");
System.out.println("++--------------------------------------------------------------------[ENTERING SYSTEM OUTPUT]-------------------------
--------------------------------------------++");
System.out.println("|| '''''''''''''''''''''' ||");
System.out.println("|| ALL CUSTOMER FOR TODAY
||");
System.out.println("|| `````````````````````` ||");
System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
customerCounter++;
32
System.out.println("|| ```````````````````` ||");
System.out.println("|| RECEIPT DATE: "+obj1.getReceiptDate()+"
");
System.out.println("|| ||");
System.out.println("|| DIAGNOSTIC STATUS: "+obj1.getDiagStatus()+"
");
System.out.println("|| ||");
System.out.println("|| INSPECTION STATUS: "+obj1.getInsStatus()+"
");
System.out.println("|| ||");
System.out.println("|| SERVICE COMP STATUS: "+obj1.getServCompStat()+"
");
System.out.println("|| ||");
System.out.println("|| RECEIPT ID: "+obj1.getReceiptID()+"
");
System.out.println("|| ||");
System.out.println(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
}
System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
admin.productArrangement();
storekeeper.display_end();
System.exit(0);
}
33
8.0 Display Information and Sample Interface
1:
2:
3:
34
4:
5:
6:
35
7:
8:
9:
10:
36
11:
12:
13:
37
14:
15:
16:
38
9.0 References
1. Normah Ahmad, Itaza Afiani Mohtar, Nur Azmina Zamani, (2020), TEACHING and
LEARNING MODULE, OBJECT ORIENTED PROGRAMMING USING JAVA,
UiTM Tapah.
2. https://www.w3schools.com/java/java_arrays.asp
3. https://www.javatpoint.com/runtime-polymorphism-in-java
4. https://www.javatpoint.com/java-io
5. https://www.w3schools.com/java/java_while_loop.asp
6. https://www.w3schools.com/java/java_for_loop.asp
7. https://www.javatpoint.com/java-joptionpane
39