0% found this document useful (0 votes)
18 views4 pages

Week6-CS111-Lab6 - 1 - Monday PDF

This lab involves implementing classes that model a store based on a UML diagram. Students will create an interface called Store, classes that implement the interface like MenSection and DressSection, and test the classes in a main method by creating objects and adding them to an ArrayList.

Uploaded by

Nini Lili
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)
18 views4 pages

Week6-CS111-Lab6 - 1 - Monday PDF

This lab involves implementing classes that model a store based on a UML diagram. Students will create an interface called Store, classes that implement the interface like MenSection and DressSection, and test the classes in a main method by creating objects and adding them to an ArrayList.

Uploaded by

Nini Lili
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/ 4

CS 111T - Lab

Programming Language 2
Computer Science Department
2023

Lab Objectives:
In this lab, a student will practice

• Declare an Interface .
• Declare a class that implements an interface.
Lab Exercise:
Given the following UML implement all the classes in the same package with all needed instance variables,
NEEDED accessor and mutators methods and constructors; then write a test application to demonstrate
the classes capabilities. Hint Abstract class are written in italic

<<interface>> Store
+ branchNumber : int = 16

+RestockRequired () : boolean

Clothes Other
- item_number: int # productType : String
# price: double -inventorybelow20: boolean
+<<Full constructor>> +<<Full constructor>>
+ DisplyType() :String
+ toString():String

MenSection WomenSection
- requested: Boolean # totalsales: double
+<<Full constructor>> +<<Full constructor>>
+ toString():String + toString():String

DressSection
-Dresstype: String
+<<full constructor>>
+ toString():String

Consider the following points:


• Make any changes you need depending on the above UML.
• Create an interface Store.
• In interface Store, branch number is a constant that identify specific branch.
• Method Restockrequired() is used to force the required classes to implement it.
• Method Restockrequired() in Other need to return true ,if the inventory is less than 20 ,
otherwise it returns false.
• Method Restockrequired() in MenSection need to return true ,if there is a request by store
manager , otherwise it returns false.
• Method Restockrequired() in DressSection need to return true ,if the totalsales is more than
2000 , otherwise it returns false.
• Method DisplyType() in MenSection return “Summer cloths”
• Method DisplyType() in Dress Section return “Items under discount”

In main:
• Create objects of classes: MenSection, DressSection, and others.
• Create an ArrayList of type Store named list .
• Add the following objects to it

Class type Item_number price Requested Total_sales Product Inventory


type below 20
Other - - - - Bags true
MenSection 4820 170 true - - -
Dress 4014 210 - 2800 - -

Assignment:
Given the following UML implement all the classes in the same package with all needed instance variables,
NEEDED accessor and mutators methods and constructors; then write a test application to demonstrate
the classes capabilities.

Consider the following points:


• Make any changes you need depending on the above UML.
• Create an interface contract.
• In interface contract, Method register () is used to force the required classes to implement
it.
• Create class summer camp which implements interface.
• Method register () in summer camp need to return true ,if duration of camp up of 15 days,
otherwise it returns false.
• Link class GymMembership with interface contact .
• Method register () in BASIC_MEMBERSHIP need to return true ,if getTotalCharge() > 1500 ,
otherwise it returns false.
• Method register () in VipMembership need to return true ,if getTotalCharge () > 1200 ,
otherwise it returns false.

In main:
• Create an ArrayList of type contact named new_list .
• Add the following objects to it

Class type name Numof Duration monthlyCharge swimmingPoolAccess


month
Summer camp • Blue Lake - 20 - -
Campground

VipMembership prime - - - -
BASIC_MEMBERSHIP Member 3 - 400 True

You might also like