Sei sulla pagina 1di 4

PROGRAMMING PARADIGM CSC305

ASSIGNMENT 2: OBJECT ORIENTED PROGRAMMING

Question 1 :
Given the following cyclingGlass and swimmingGlass subclass are inherited from sportVissionShoppe superclass Superclass : sportVisionShoppe Attributes: String custOrderNo String custOrderDate float depositPymt

// customer order number // date of order

Abstract Method: public abstract double calCharges() Subclass : cyclingGlass

//method to calculate the price

Attributes: char type_glass // T Transition Glass, P Polarized glass, I Iridium glass boolean uvProtection; // with UV protection extra RM 30 will be charge to the total price Float depositPymt Method: public double calCharges() public String toString()

//method to calculate the price // method to display the data members

Details of charges are shown in table 4.1 below: Glass Type Transition Polarized Iridium Price RM 300.00 RM 350.00 RM 400.00 Table 4.1 Subclass : swimmingGlass Attributes: char Type; String style;

// A Anti-fogging google, S short-sighted googlr // Retro, Warrior or Modern

Method: public double calCharges() public String toString()

//method to calculate the price // method to display the data members

PROGRAMMING PARADIGM CSC305


Details of charges are shown in table 4.2 below: Style and Discount Glass Type Price Retro Anti-Fogging google Short-sighted google RM 150.00 RM 250.00 Table 4.2 a) Write a class definition for super class and all sub classes b) Write a program to determine and display the number of customer who buy cycling and swimming glass from the sportVisionShoppe c) Write a program to calculate the total charges for all customers who bought Retro goggle at the sportVisionShoppe outlet. d) Write a program to list the deposit paid by the customer who bought transition cycling glass from this shop, 7% 5% Warrior 30% 20% Modern 10% 7%

Question 2 :
The following subclasses named SinglePackage and FamilyPackage are inherited from the superclass named Customer. The vacation package can be divided into two types of packages ; either Single Package or Family Package. Single Package means you came as a single (individual) person, while the Family Package means you came with a group of people or family.

Superclass : Customer Attributes : String name; String icNum; int day; boolean member; //customer name //IC number of a customer //number of days staying in the resort //whether a customer has a membership //with the resort or not.

Methods : public Customer(String, String, int, Boolean); // normal constructor public String getName(); //to return the customer name public int getDay(); //to return the number of days staying //in the resort public double memberDiscount(); //to return the membership discount Abstract Methods : abstract public double totalCharges();

PROGRAMMING PARADIGM CSC305


Subclass : SinglePackage Attributes : boolean additionalPromotion;

//either the customer prefer to have //additional promotion such as snorkeling // or a trip to an island.

Methods : public SinglePackage(String, String, int, boolean, boolean); //normal constructor public double totalCharges(); //to return the total charges for //Single Package

public boolean getAdditionalPromotion();

public double promotion();

//to return true or false whether //the customer having the //additional promotion or not //to return the additional //promotion charges.

Subclass : FamilyPackage Attributes : int numberOfApartment; boolean beachGame;

//number of apartments booked //either the customer prefer to //have a beach game

Methods : public FamilyPackage(String, String, int, Boolean, int, Boolean); //normal constructor public double totalCharges(); //to return the total charges for //Family Package public int getNumberOfApartment(); //to return number of apartments //booked public double beachGame(); //to return the charges for beach //game

The details of packages are as follows : The charge for a single apartment is RM80 per day. 25% discount from the total charges will be given if the customer has a membership with the resort. The amount of RM150 will be charges to customer if they choose additional promotion under the single package. The charges for beach game is RM100, if the customer choose the beach game for the family package.

PROGRAMMING PARADIGM CSC305

Write an application program to : store customer data obtains from the user. Display the total number of customers for each SinglePackage and FamilyPackage. Display the number of customers for SinglePackage that chooses additional promotion and its total charges.

Potrebbero piacerti anche