100% found this document useful (2 votes)
6K views

CSC186 Group Assignment - Printing Service

This document contains code for a printing service program with the following: 1. There are 3 classes - PrintingService, PhotoAlbum, and Photostat that inherit from PrintingService. 2. PrintingService contains customer name and number attributes. PhotoAlbum contains size, quantity, and album attributes. Photostat contains ink type and quantity. 3. Each class has accessor and mutator methods to get/set attributes as well as toString methods to return details. PhotoAlbum and Photostat also have methods to calculate total prices.

Uploaded by

Syahirah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
6K views

CSC186 Group Assignment - Printing Service

This document contains code for a printing service program with the following: 1. There are 3 classes - PrintingService, PhotoAlbum, and Photostat that inherit from PrintingService. 2. PrintingService contains customer name and number attributes. PhotoAlbum contains size, quantity, and album attributes. Photostat contains ink type and quantity. 3. Each class has accessor and mutator methods to get/set attributes as well as toString methods to return details. PhotoAlbum and Photostat also have methods to calculate total prices.

Uploaded by

Syahirah
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

CSC186 - OBJECT ORIENTED PROGRAMMING

GROUP ASSIGNMENT
TITLE: PRINTING SERVICE

LIST OF GROUP MEMBER:


NAME MATRIC NO.
MUHAMMAD IZZAN BIN BORHAN 2019977899
SITI SYAHIRAH BINTI MANSOR 2019778649
MUHAMMAD DANIAL BIN SHAH RIZAL 2019292702

GROUP NAME: M3CS1104A

LECTERUR NAME:
MADAM ZAMLINA BINTI ABDULLAH

1
CSC 186 – PROJECT REPORT EVALUATION RUBRIC
No Assessment Score Weight Total Score Total
Criteria Obtained
1 2 3 4 5 W W x Score
1 Table of Content No page Some page All page NA NA 1 3
numbers numbers are numbers
listed. wrong. being entered
accordingly.
2 Introduction Poor Fair Satisfactory Good Excellent 2 10
description description description descriptiondescription
and no and lack of and a few of and many and many
clear ideas clear ideas. clear ideas. clear ideas.
clear &
at all. creative
ideas.
3 Project Objectives Objectives One/ two Two Two Two 2 10
are not objective(s) objectives objectives objectives
relevant at with no with with good with
all. explanation. satisfactory explanation. excellent and
explanation. concise
explanation.
4 UML diagrams Poor UML Fair UML Satisfactory Good UML Perfect UML 3 15
diagram diagrams with UML diagram diagrams with diagram
with many 7 errors. with 6 errors. at most 5 without any
errors errors. error.
5 Program code The The program The program The program The program 3 15
program is meets only 2 meets only 3 meets all meets all
wrong, requirements. requirements. requirements. requirements
incomplete Include good and optional
and cannot convention requirement
be standard and with
executed. comments. excellent
outcome.

2
6 Sample input and Not At least one Common/sta Good display Provides 2 10
output relevant of input file or ndard display for input and excellent
input and one output for input and output. user
output file. output. interface and
sample. creative
output.
7 References One More than NA NA NA 1 2
reference. one
references.

TOTAL MARKS 65

3
TABLE CONTENT

NO. TITLE PAGE

1 Introduction & Objectives 5


2 Class Diagram 6
3 Use Case Diagram 7
4 Program Code 8-18
5 Output 19-20
6 References 21

4
INTRODUCTION
This is a Printing Service Java Program. It consist of 2 attributes which are customer
name and telephone number. This program is to serve printing material according to the
client request. This printing service offer Photostat service and photo album service. Each
service offer different prices depending on size and type the customer choose.
The system can be used by customer and can view the total payment. Next, the employee
can take order and make payment for each customers.

Objectives
 To enhance our knowledge in Java coding.
 Facilitate customer affairs.
 To calculate total price for each categories.

5
CLASS DIAGRAM

 Class Printing Service has two private attributes and two classes inherits from it which is
class Photo album and Photostat.
 Class photo album has three private attributes which is size, quantity, album.
 Class Photostat has two private attributes which is ink type and quantity.
 All of this classes has accessor method and printer method.

6
USE CASE DIAGRAM

7
PROGRAM CODE
Class PrintingService
public class PrintingService
{
private String custName;
private String numTel;

//default constructor
public PrintingService()
{
custName = "";
numTel = "";
}

//normal constructor
public PrintingService(String cn, String nt)
{
custName = cn;
numTel = nt;
}

//accessor
public String getCustName()
{
return custName;
}

public String getNumTel()


{

8
return numTel;
}

//mutator
public void setPrintingService(String cn, String nt)
{
custName = cn;
numTel = nt;
}

//printer
public String toString()
{
return "\n Customer name: " + custName +
"\n Telephone number: " + numTel;
}
}

9
Class PhotoAlbum
public class PhotoAlbum
{
private char size;
private int qty;
private int album;

//default constructor

public PhotoAlbum()
{
size = 0;
qty = 0;
album = 0;
}

//normal constructor
public PhotoAlbum(char s, int q, int a)
{
size = s;
qty = q;
album = a;
}

//accessor
public char getSize()
{
return size;
}

10
public int getQty()
{
return qty;
}

public int getAlbum()


{
return album;
}

//mutator
public void setPhotoAlbum(char s, int q, int a)
{
size = s;
qty = q;
album = a;
}

//processor
public double calcTotalPrice()
{
double price = 0;
if(size =='A' || size =='a')
{
price = 2.50 * qty;
}
else if(size == 'B' || size =='b')
{
price = 5.00 * qty;
}

11
else if(size == 'C' || size == 'c')
{
price = 7.50 * qty;
}

return price;
}

//printer
public String toString()
{
return
"\n Size of photo album: " + size +
"\n Quantity of photo: " + qty + "pcs" +
"\n Album: " + album;
}
}

12
Class Photostat
public class Photostat
{
private String inkType;
private int quantity;

//default constructor
public Photostat()
{
inkType= "";
quantity = 0;
}

//normal constructor
public Photostat(String it, int qt)
{
inkType = it;
quantity = qt;
}

// acessor
public String getInk()
{
return inkType;
}

public int getQuantity()


{
return quantity;
}

13
//mutator
public void setPhotostat(String it, int qt)
{
inkType = it;
quantity = qt;
}

//processor
public double determineInkType()
{
double total =0;
if(inkType.equalsIgnoreCase("BW") || inkType.equalsIgnoreCase("bw"))
{
total = quantity* 0.10;
}
else if(inkType.equalsIgnoreCase("C") || inkType.equalsIgnoreCase("c"))
{
total = quantity * 0.20;
}

return total;
}
//printer
public String toString()
{
return "\n Type of ink: " + inkType +
"\n Quantity: " + quantity ;
}
}

14
Class PrintingApp
import java.util.*;
public class PrintingApp
{
public static void main(String[] args)
{
int service, album;
String name, numTel, inkType;
char size;

// Ask user to input name and telephone number


Scanner s = new Scanner(System.in);
PrintingService p1 = new PrintingService();
PhotoAlbum p2 = new PhotoAlbum();
Photostat p3 = new Photostat();
System.out.println("******** Welcome to Printing Service ********");
System.out.println("Enter your name: ");
name = s.next();
System.out.println("Enter your phone number: ");
numTel = s.next();

// Ask user to choose category according to the given number


System.out.println("\nChoose your category:-");
System.out.println("Category 1: Photo Album Service");
System.out.println("Category 2: Photostat Service\n");
System.out.println("Please enter the number of category:");
service = s.nextInt();
p1.setPrintingService(name,numTel);

15
if(service==1)
{
// Display type of size photo of Photo Album Service
System.out.println("Category: Photo Album Service");
System.out.println("Type of Size Photo:-");
System.out.println("Size A for 10cmx10cm, RM2.50 per photo");
System.out.println("Size B for 12cmx12cm, Rm5.00 per photo");
System.out.println("Size C for 14cmx14cm, RM7.50 per photo");
System.out.println("All the details order for photo album service for today\n");

// Ask user to enter size, quantity of photo and quantity of album


System.out.println("Please enter your size (A/B/C): ");
size = s.next().charAt(0);
System.out.println("Quantity: ");
int quantity = s.nextInt();
System.out.println("Quantity of album: ");
album = s.nextInt();
p2.setPhotoAlbum(size,quantity,album);
double price = p2.calcTotalPrice();

else if(service == 2)
{
// Display type of ink that use for Photostat Service
System.out.println("Category: Photostat Service");
System.out.println("Type ink used for Photostat: ");
System.out.println("Black & White: 0.10 per paper");
System.out.println("Color: 0.20 per paper");
System.out.println("All the details order for photostat service for today\n");

16
// Ask user to enter ink type and quantity of paper
System.out.println("Please enter type of ink (BW/C): ");
inkType = s.next();
System.out.println("Quantity: ");
int quantity1 = s.nextInt();
p3.setPhotostat(inkType,quantity1);
double total1 = p3.determineInkType();
}

// Display all information

System.out.println("\n*******************************************************************\n");
System.out.println("Customer details:" + p1.toString());
System.out.println(" Category:" + service);

if (service==1)
{
// To calculate total price for Photo Album Service
System.out.println("Details:" + p2.toString());
System.out.println(" Total price: RM " + p2.calcTotalPrice());

}
else if(service==2)
{
// To calculate total price for Photostat Service
System.out.println("Details:" + p3.toString());
System.out.println(" Total price: RM " + p3.determineInkType());
}

17
System.out.println("\nThank you for supporting us! Look forward to serving you
again.");
System.out.println("\n*******************************************************************");

18
OUTPUT

19
20
REFERENCES

 https://www.w3schools.com/java/default.asp
 PowerPoint Chapter 2 - UML
 PowerPoint Chapter 3 - Use Case

21

You might also like