0% found this document useful (0 votes)
5K views39 pages

CSC186 Group Project 2022

The document describes a class definition for inheritance and polymorphism in Java. It defines a super Customer class with attributes like name, password, user ID, item count. The Customer class has abstract method calculateTotal to be implemented by subclasses. It also defines methods like verifyLogin, updateProfile, addToCart etc. The Services class is also defined with attributes like service, product and courier choice.

Uploaded by

AMIR HAFIZI MUSA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5K views39 pages

CSC186 Group Project 2022

The document describes a class definition for inheritance and polymorphism in Java. It defines a super Customer class with attributes like name, password, user ID, item count. The Customer class has abstract method calculateTotal to be implemented by subclasses. It also defines methods like verifyLogin, updateProfile, addToCart etc. The Services class is also defined with attributes like service, product and courier choice.

Uploaded by

AMIR HAFIZI MUSA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

FACULTY OF COMPUTER AND MATHEMATICAL SCIENCES

DIPLOMA OF COMPUTER SCIENCE (CS110)

PROJECT CSC186 REPORT

PROJECT TITLE: Computer Store System Management


GROUP: A4CS1102C
GROUP NUMBER: 4
GROUP MEMBERS:
NAME STUDENT ID
1. AMIR HAFIZI BIN MUSA 2021821626

2. AMIRUL FARIZ BIN ZAHARI 2021821588

3. MOHAMAD MUAZ BIN MAHADI 2021624854


4. MOHAMAD AZRUL AIMAN BIN 2021861144
ABDUL RASID

PREPARED FOR:

NAME

MADAM ITAZA AFIANI MOHTAR


Table of Content

Items Page

1.0 Organizational Structure 3

2.0 Introduction 4-6

3.0 Objective 6

4.0 UML Diagram


• 4.1 Class Diagram 7-8
• 4.2 Use Case Diagram

5.0 Input Data 9-11

6.0 Class Definition of Inheritance and Polymorphism 12-26

7.0 Class Application 27-33

8.0 Display Information and Sample Interface 34-38

9.0 References 39

2
1.0 ORAGANIZATIONAL STRUCTURE

3
2.0 INTRODUCTION

Computers are a technology that is familiar and has become common to


society, it has become a necessity that needs to be used in daily life. With
Internet being a median that has no limit and barriers, computer services and
products have become a necessity for the masses.
XenoTec Enterprise is a Computer Store that just started its operation in
August 2021. As they just started their business, they would be requiring to
develop a system to manage their store and online shopping system. A
system for managing their online store system is a must as it would help
them to manage their products, orders and scheduling services much easier
as it would be automated by the computer. With the help of online store
system, it would also prevent the store from being overcrowded by the
customers during the operation hours. Below is the table for selected
services only that are being provided by the computer store.

Table 1

Menu Code Main Menu

1 Services
2 Browse Products

Table 1.1

Service Code Services Name Price (RM)

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

1 AMD Radeon R7 350 2GB RM 100

2 Intel Xeon X5670 @2.9Ghz RM 90

3 KaZe SODIMM DDR4 4GB 2400Mhz RM 80

4 KaZe DIMM DDR4 4GB 3200Mhz RM 75

5 KaZe WGC2 Veno II Dual Mode Wireless Mouse RM 55

6 20000mAh Portable Powerbank With Digital Display RM 40

7 KaZe Mechanical Keyboard (MK853) Sakura Edition RM 150

8 USB Flash Drive 8GB RM 15

9 KaZe 95mb/s 633x Micro SD Card RM 45

10 KaZe SSD SATA III 2.5 Inch 128GB RM 69

Table 1.3
COURIER Services Name Price
CODE

1 POS Laju RM 4.50

2 J&T Express RM 4.60

3 DHL Express RM 4.70

4 Skynet RM 5.00

5 Ninja Van RM 4.40

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

1. To let user have the control over the interface.

2. To let user choose which services that they want.

3. To manage services, schedules, and products.

4. To calculate the services total for the customer.

5. To let user make payment for the selected services.

6. To generate the receipt for the customer.

7. To calculate the total daily revenue.

8. To calculate and update the estimation of revenue based on days input.

6
4.0 UML DIAGRAM

4.1 Class 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:

INPUT 10: INPUT 11:

9
INPUT 12: INPUT 13:

INPUT 14: INPUT 15:

INPUT 16:

INPUT 17: INPUT 18:

INPUT 19: INPUT 20:

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;

public abstract class Customer {

private String name;


private String pass;
public String userName;
public String userPass;
private int oriCusID;
private int countLoop;
private int totalItem;

//Create CLASSES
Scanner in = new Scanner(System.in);
Random rand = new Random();

public Customer(){
userName = "";
userPass = "";
oriCusID = 0;
totalItem = 0;
}

public Customer(String un, String up, int cus, int tl){


userName = un;
userPass = up;
oriCusID = cus;
totalItem = tl;
}

//GET METHODS FOR PRIVATE VARIABLES


public String getUserName() {
return userName;
}

public String getUserPass() {


return userPass;
}

public int getOriCusID(){


return oriCusID;
}

public int getItemInCart(){


return totalItem;
}

//SET METHODS FOR PRIVATE VARIABLES


public String setName(String newUserName) {
return userName = newUserName;
}

public String setPass(String newUserPass) {


return userPass = newUserPass;
}

12
public void setCusID() {
int cusID;
cusID = rand.nextInt(100000);
oriCusID = cusID;
}

//START OF METHODS PROCESSES


public boolean verifyLogin() {

boolean verifyLogin = true;


int loginLoop = 1;

while(loginLoop == 1) {
System.out.println("\nSIGNING YOU IN :)");
System.out.println("Enter your username: ");
name = in.nextLine();

System.out.println("Enter your password: ");


pass = in.nextLine();

if(name.equals(userName) && pass.equals(userPass)) {

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;
}

//UPDATE THE PROFILE INFO


public void updateProfile() {
System.out.println("\nSIGNING YOU UP TO OUR SYSTEM");
System.out.println("Enter you designated username: ");
userName = in.nextLine();

System.out.println("Enter your designated password: ");


userPass = in.nextLine();

System.out.println("Your Profile has been updated");


}
//Customer Information
public void customerinfo() {

System.out.println("\nTHIS IS YOUR PERSONAL INFORMATION:");


System.out.println("Customer Username: "+userName+"\nCustomer Password: "+userPass+"\nCustomer ID:
"+oriCusID);
System.out.println("Items in your cart: "+countLoop+"\n");
}

13
public void addToCart() {
countLoop++;
totalItem = countLoop;
}

public String toTring(){


return("Customer Username: "+userName+"\nCustomer Password: "+userPass+"\nCustomer ID: "+oriCusID+"\nTotal
Items In Cart: "+totalItem);
}

public abstract double calculateTotal(double calculateTA, int itemTotal);

2:
import java.util.Scanner;

public class Services {

Scanner in = new Scanner(System.in);

private int serviceChoose;


private int productChoose;
private int courierChoose;

private int product_id;


private int service_id;
private int courier_id;

private double productPrice;


private double courierCharge;
private double serviceCharge;

private String appointment;


private String courierName;
private String productName;
private String serviceName;

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;
}

public int getproductChoose()


{
return productChoose;
}

public int getcourierChoose()


{
return courierChoose;
}

public int getproduct_id()


{
return product_id;
}

public int getservice_id()


{
return service_id;
}

public int getcourier_id()


{
return courier_id;
}

public double getproductPrice()


{
return productPrice;
}

public double getcourierCharge()


{
return courierCharge;
}

15
public double getserviceCharge()
{
return serviceCharge;
}

public String getappointment()


{
return appointment;
}

public String getcourierName()


{
return courierName;
}

public String getproductName()


{
return productName;
}

public String getserviceName()


{
return serviceName;
}

public void RequestCourier(){


System.out.println("\n----COURIER SELECTION-----");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | COURIER CODE | [SERVICES NAME] | PRICE | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Courier 1 | POS Laju | RM 4.50 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Courier 2 | J&T Express | RM 4.60 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Courier 3 | DHL Express | RM 4.70 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Courier 4 | Skynet | RM 5.00 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Courier 5 | Ninja Van | RM 4.40 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");

System.out.println("COURIER 1: POS Laju\nCOURIER 2: J&T Express\nCOURIER 3: DHL Express\nCOURIER 4:


Skynet\nCOURIER 5: Ninja Van");

System.out.println("\n\nINPUT: ");
courierChoose = in.nextInt();

if(courierChoose == 1){

courierName = "POS Laju";


courier_id = 4044;
courierCharge = 4.50;
}
else if(courierChoose == 2){
courierName = "J&T Express";
courier_id = 2022;
courierCharge = 4.60;
}
16
else if(courierChoose == 3){
courierName = "DHL Express";
courier_id = 5055;
courierCharge = 4.70;
}
else if(courierChoose == 4){
courierName = "Skynet";
courier_id = 1011;
courierCharge = 5.00;
}
else if(courierChoose == 5){
courierName = "Ninja Van";
courier_id = 3033;
courierCharge = 4.40;
}
System.out.println("\n----YOUR NEWEST SELECTED COURIER WILL BE SET AS THE LATEST ONE-----");
}

public void productPrice(){


System.out.println("\n-----PRODUCT SELECTION-----");
System.out.println("\nINPUT: ");
productChoose = in.nextInt();

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 == 4){


productName = "KaZe DIMM DDR4 4GB 3200Mhz";
product_id = 3982;
productPrice = 75.00;

}
else if(productChoose == 5){
productName = "KaZe WGC2 Veno II Dual Mode Wireless Mouse";
product_id = 6789;
productPrice = 55.00;

else if(productChoose == 6){


productName = "20000mAh Portable Powerbank With Digital Display";
product_id = 8721;
productPrice = 40.00;
17
else if(productChoose == 7){
productName = "KaZe Mechanical Keyboard (MK853) Sakura Edition";
product_id = 9182;
productPrice = 150.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;

public void serviceChoose()


{
System.out.println("\n-----SERVICES SELECTION-----");
System.out.println("\nINPUT: ");
serviceChoose = in.nextInt();

if(serviceChoose == 1){

System.out.println("\nYou have chosen the diagnostic option\n");

serviceName = "Diagnostic";
serviceCharge = 170;

}
else if(serviceChoose == 2){

System.out.println("\nYou have chosen the inpsection option");

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(" +-----------------------------------------------------------------------------------------+ ");

//Processor methods for browsing the products


public void browseProduct()
{
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | PRODUCT NUM. | PRODUCT NAME | PRICE | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 1 | AMD Radeon R7 350 2GB | RM 100 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 2 | Intel Xeon X5670 @2.9Ghz | RM 90 | ") ;
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 3 | KaZe SODIMM DDR4 4GB 2400Mhz | RM 80 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 4 | KaZe DIMM DDR4 4GB 3200Mhz | RM 75 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 5 | KaZe WGC2 Veno II Dual Mode Wireless Mouse | RM 55 |
");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 6 | 20000mAh Portable Powerbank With Digital Display | RM 40 |
");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 7 | KaZe Mechanical Keyboard (MK853) Sakura Edition | RM 150 |
");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 8 | USB Flash Drive 8GB | RM 15 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 9 | KaZe 95mb/s 633x Micro SD Card | RM 45 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");
System.out.println(" | Product 10 | KaZe SSD SATA III 2.5 Inch 128GB | RM 69 | ");
System.out.println(" +----------------+--------------------------------------------------+---------------------+ ");

public String appointmentDate(){


System.out.println("\n----SETTING APPOINTMENT----");
System.out.println("\nPlease enter your selected appoinment date | [Day/Month/Year] e.g: 10/08/2022 |");

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;

public class Checkout extends Customer{

Scanner in = new Scanner(System.in);

// instance variables
private double total;
private double tax;
private double totalTax;

private String bankName;


private String bankUsername;
private String bankPass;

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;
}

//mutator methods for the Checkout


public void settotal (double t) {
total = t;
}

public void settax(double tx) {


tax = tx;
}

20
//Accessor methods for the Checkout
public double gettotal(){
return total;
}

public double gettax(){


return tax;
}

public double gettotalTax(){


return totalTax;
}

public String getBankName(){


return bankName;
}

public String getBankUsername(){


return bankUsername;
}

public String getBankPass(){


return bankPass;
}

public double calculateTotalTax(int totalIT){


totalTax = 0;
tax = 0.09;
totalTax = totalIT*tax;

return totalTax;
}

//Processor methods for the Checkout


public double calculateTotal(double ctAmount, int totalI)
{
total = 0.0;
double TT = 0;
tax = 0.09;
TT = totalI * tax;

total = ctAmount + TT;

if(totalI >= 5){


total = total * 0.91;
}

return total;
}

//Processor methods for the Checkout


public boolean makePayment()
{
boolean makePayment = false;
int mpLoop = 1;

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;

public class Admin extends Services{

Scanner in = new Scanner(System.in);

private String diagStatus;


private String insStatus;
private String servCompStat;
private double servPrice;

//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;
}

public String getInsStatus() {


return insStatus;
} //inspection status

public String getServCompStat() {


return servCompStat;
} //service computer status

public double getServPrice() {


return servPrice;
} //service price

public void setAdmin(String ds,String is,String sc,double sp)


{
insStatus = is;
diagStatus = ds;
servCompStat = sc;
servPrice = sp;
}

public void resetServPrice(){


servPrice = 0;
}

public void setServPrice(){


servPrice = 10.00;
}
public void productArrangement()
{
System.out.println("
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~+");
System.out.println(" + PRODUCTS ARRANGEMENT AND CURRENT STOCK
INFORMATION +");
System.out.println(" + +");
System.out.println("
+=====================+=====================+=======================+===============================
==========================+");
System.out.println(" !! | | | |");
System.out.println(" !! DATE | PRODUCT ID | CURRENT STOCK | Additional
Notes |");
System.out.println(" !!____________________+_____________________+______________________
+_________________________________________________________|");
System.out.println(" !! | | | |");
System.out.println(" !! | | | |");
System.out.println(" !! 15/07/2022 | 4428 | 28574 | NEW STOCK IN 170
DAYS |");
System.out.println(" !! | | | |");

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");
}

public void scheduleAppoint1()


{

diagStatus = "TRUE";
servCompStat = "TRUE";

}
public void scheduleAppoint()
{

insStatus = "TRUE";
servCompStat = "TRUE";

public void resetScheduleAppoint(){


diagStatus = "FALSE";
insStatus = "FALSE";
servCompStat = "FALSE";
}

public String toString()


{
return ("\nINSPECTION STATUS : "+ insStatus +"\nSERVICE COMPUTER STATUS : "+ servCompStat +"\nSERVICE PRICE : "+
servPrice);
}

24
3:
import javax.swing.JOptionPane;
import java.util.Random;
import java.text.DecimalFormat;

public class StoreKeeper extends Admin{

Random rand = new Random();


DecimalFormat df = new DecimalFormat("0.00");

private int receiptID;


private int itemQuantity;
private double dailyIncome;
private double monthlyIncome;
private String storeName;
private String receiptDate;

private int day;


private double estimatedMonthlyIn;

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;
}

public double getDailyIncome() {


return dailyIncome;
}

public int getReceiptID() {


return receiptID;
}

public String getReceiptDate() {


return receiptDate;
}
public String getStoreName() {
return storeName;
}

public int getItemQuantity() {


return itemQuantity;
}

public double getMonthlyIncome() {


return monthlyIncome;
}

25
public void setreceiptID() {
int repID;
repID = rand.nextInt(100000);
receiptID = repID;
}

public void setStoreKeeper(double d,int ri,String rd,String sn,int iq,double m)


{
dailyIncome = d;
receiptID = ri;
receiptDate = rd;
storeName = sn;
itemQuantity = iq;
monthlyIncome = m;
}

public String toString()


{
return("RECEIPT ID : "+ receiptID +"\nRECEIPT DATE : "+ receiptDate +"\nSTORE NAME : "+storeName+"\nITEM QUANTITY :
"+itemQuantity);
}

public double generateDailyRev(double amountDR)


{
double totalDailyIncome = 0;
totalDailyIncome = (totalDailyIncome + amountDR);
return totalDailyIncome;
}

public double updateMonthlyIncome(double amountDI)


{
String input10 = JOptionPane.showInputDialog("UPDATING AND ESTIMATING THE TOTAL MONTHLY INCOME\n\n
CURRENT MONTHLY INCOME IS: RM"+df.format(amountDI)+"\n\nPLEASE ENTER THE AMOUNT OF DAYS FOR THE
ESTIMATION OF TOTAL AVERAGE REVENUE BASED ON THE DAYS INPUT \n INPUT: [DAYS]");
day = Integer.parseInt(input10);

double estimatedMonthlyIn;
estimatedMonthlyIn = day * amountDI;
monthlyIncome = estimatedMonthlyIn;
return monthlyIncome;

public void display_end()


{
System.out.println("\n\n [THE END OF THE SYSTEM]
");
}

26
7.0 Class Application
Main
import java.util.Scanner;
import javax.swing.JOptionPane;
import java.text.DecimalFormat;

public class CSMain {

public static void main (String []args) {


//IMPORT SCANNER FOR USER INPUT
Scanner in = new Scanner(System.in);
DecimalFormat df = new DecimalFormat("0.00");
double total_end = 0;
double total_tax = 0;
double total_holder = 0;
double total_holder2 = 0;
double total_holder3 = 0;
double total_holder4 = 0;

double total_serv = 0;
double total_browse = 0;

System.out.println("HELLO AND WELCOME!!\n");


System.out.println("Before using the system, please enter the max amount of customer first!!");
System.out.println("Thank you!\n");

String input1 = JOptionPane.showInputDialog("Enter the max amount of customer!");


int arrayAmount = Integer.parseInt(input1);
String chosenMainMenu = "";

Customer[] customerC = new Customer[arrayAmount];


Services[] services = new Services[arrayAmount];
Admin admin = new Admin();
StoreKeeper storekeeper = new StoreKeeper();

for(int i=0; i<customerC.length; i++) {

//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();

//LOOP FOR THE MAIN SYSTEM IF USERNAME AND PASS IS INCORRECT


if(newCustomer.equalsIgnoreCase("yes")) {
customerC[i].updateProfile();
passOrfail_newHere = "false";
}
else if(newCustomer.equalsIgnoreCase("no")){
System.out.println("\nThis is your first time launching the system, please sign up first!!\n");
customerC[i].updateProfile();
passOrfail_newHere = "false";
}
else{
System.out.println("\nPLEASE ENTER CORRECTLY!!! TRY AGAIN!!!\n");
passOrfail_newHere = "yes";
}

//Method Declaration
customerC[i].verifyLogin();

System.out.println("Do you want to view your account information? [ YES | NO ]");


viewAccount = in.nextLine();

if(viewAccount.equalsIgnoreCase("yes")) {
customerC[i].customerinfo();
}
else{
}

while(end_system.equalsIgnoreCase("no")) {

//RESET yes_loop to "yes"


yes_loop = "yes";

while(yes_loop.equalsIgnoreCase("yes")) {

if(yes_loop.equalsIgnoreCase("yes")) {
customerC[i].addToCart();
}

System.out.println("\n---You Will Be Directed to The Main Menu---\n");


mainmenu_Loop = "yes";

while(mainmenu_Loop == "yes"){

//LOOP FOR ADMIN, CHECKOUT, SERVICES, STOREKEEPER, CUSTOMER

System.out.println(" +----------------+--------------------------------------------------+ ");


System.out.println(" | MENU CODE | [MAIN MENU] | ");
System.out.println(" +----------------+--------------------------------------------------+ ");
System.out.println(" | Menu 1 | Services | ");
System.out.println(" +----------------+--------------------------------------------------+ ");
System.out.println(" | Menu 2 | Browse Products | ");
System.out.println(" +----------------+--------------------------------------------------+ ");

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();

chosenMainMenu = "Services Option";

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();

chosenMainMenu = "Browse Option";

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_holder6 = total_holder6 + total_browse + total_serv;

System.out.println("THE AMOUNT OF TOTAL: RM"+total_holder6+"\n");

System.out.println("Do you want to buy another item? [ YES | NO ]");


in.nextLine();
yes_loop = in.nextLine();

total_tax = checkout.calculateTotalTax(customerC[i].getItemInCart());

System.out.println("\nTHE TOTAL TAX AMOUNT: RM"+total_tax);


//METHOD FOR CALCULATION
total_ultimate = checkout.calculateTotal( total_holder6, customerC[i].getItemInCart());

System.out.println("\nDo you want to view your account information? [ YES | NO ]");


viewAccount = in.nextLine();

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();

//CLASS TO CLASS PARSE


int totalItems = customerC[i].getItemInCart();

//FOR CLASS CUSTOMER CONSTRUCTOR


String name = customerC[i].getUserName();
String password = customerC[i].getUserPass();
int userID = customerC[i].getOriCusID();
int totalItem = customerC[i].getItemInCart();

//FOR CLASS SERVICES CONSTRUCTOR


int serviceChoose = services[i].getserviceChoose();
int productChoose = services[i].getproductChoose();
int courierChoose = services[i].getcourierChoose();

int product_id = services[i].getproduct_id();


int service_id = services[i].getservice_id();
int courier_id = services[i].getcourier_id();

30
double productPrice = services[i].getproductPrice();
double courierCharge = services[i].getcourierCharge();
double serviceCharge = services[i].getserviceCharge();

String appointment = services[i].getappointment();


String courierName = services[i].getcourierName();
String productName = services[i].getproductName();
String serviceName = services[i].getserviceName();

//FOR CHECKOUT CLASS BRINGBACK


double totalC = total_ultimate;
double taxC = checkout.gettotalTax();
String bankName = checkout.getBankName();
String bankUsername = checkout.getBankUsername();

//FOR ADMIN CLASS BRINGBACK


String DiagStatus = admin.getDiagStatus();
String InsStatus = admin.getInsStatus();
String servCompStat = admin.getServCompStat();
double servPrice = admin.getServPrice();

//FOR DAILY AND MONTHLY


total_end_holder = total_ultimate;
total_end = total_end + total_end_holder;

//FOR STOREKEEPER CLASS BRINGBACK


int receiptID = storekeeper.getReceiptID();
int itemQuantity = customerC[i].getItemInCart();
double dailyIncome = total_end;
double monthlyIncome = storekeeper.getMonthlyIncome();
String storeName = storekeeper.getStoreName();
String receiptDate = storekeeper.getReceiptDate();

//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;

//CALCULATE DALILY INCOME


double dailyIn = 0;
dailyIn = storekeeper.generateDailyRev(total_end);

//CALCULATE MONTHLY INCOME


double monthlyIn = 0;
monthlyIn = storekeeper.updateMonthlyIncome(dailyIn);

//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(":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");

for(int m = 0; m<customerC.length; m++){

customerCounter++;

if(customerC[m] instanceof Checkout){


obj = (Checkout) customerC[m];
System.out.println("|| ||");
System.out.println("|| CUSTOMER NUMBER: "+customerCounter+"
||");
System.out.println("|| ||");
System.out.println("|| USERNAME: "+customerC[m].getUserName()+"
");
System.out.println("|| ||");
System.out.println("|| PASSWORD: "+customerC[m].getUserPass()+"
");
System.out.println("|| ||");
System.out.println("|| CUSTOMER ID: "+customerC[m].getOriCusID()+"
");
System.out.println("|| ||");
System.out.println("|| TOTAL ITEM IN CART: "+customerC[m].getItemInCart()+"
||");
System.out.println("|| ||");
System.out.println("|| TOTAL PAYMENT: RM"+df.format(obj.gettotal())+"
");
System.out.println("|| ||");
System.out.println("|| TOTAL TAX CHARGE: RM"+obj.gettotalTax()+"
||");
System.out.println("|| ||");
System.out.println("|| BANK NAME: "+obj.getBankName()+"
");
System.out.println("|| ||");
System.out.println("|| BANK USERNAME: "+obj.getBankUsername()+"
");
System.out.println("|| ||");
}

if(services[m] instanceof StoreKeeper){


obj1 = (StoreKeeper) services[m];

System.out.println("|| SHIPPING INFORMATION


||");
System.out.println("|| ```````````````````` ||");
System.out.println("|| COURIER ID: "+services[m].getcourier_id()+"
||");
System.out.println("|| ||");
System.out.println("|| COURIER NAME: "+services[m].getcourierName()+"
");
System.out.println("|| ||");
System.out.println("|| ||");
System.out.println("|| ||");
System.out.println("|| APPOINTMENT INFORMATION
||");
System.out.println("|| ````````````````````` ||");
System.out.println("|| APPOINTMENT DATE: "+services[m].getappointment()+"
");
System.out.println("|| ||");
System.out.println("|| ADDITIONAL INFORMATION
||");

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(" ........................ ");


System.out.println("++---------------------------------------------------------------------[ENTERING ADMIN DASHBOARD]-------------------
--------------------------------------------------++");
System.out.println("|| '''''''''''''''''''''''' ||");
System.out.println("|| ++----------------++-------------------------------------------------------------++
|| ");
System.out.println("|| || STORE NAME || "+obj1.getStoreName()+" ||
||");
System.out.println("||
++________________++_____________________________________________________________++ ||");
System.out.println("|| || || || ||");
System.out.println("|| || DAILY INCOME || RM "+df.format(dailyIn)+"
");
System.out.println("||
++________________++_____________________________________________________________++ ||");
System.out.println("|| || ESTIMATED || || ||");
System.out.println("|| || DAYS INCOME || RM "+df.format(monthlyIn)+"
");
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

You might also like