IT2030 - Object Oriented Programming-Version D
IT2030 - Object Oriented Programming-Version D
IT2030 - Object Oriented Programming-Version D
Student ID:
Machine N 0:
Duration: 3 Hours
November 2023
Instructions to Candidates:
• This paper contains four questions. Answer All Questions.
• Marks for each question are given on the paper. Total Marks: loo.
:.gr • Create a folder on the Desktop with your student registration number and store all your
program files inside that.
• Create a separate Project for each question. The name of the project is provided in the
question.
• This paper contains 08 pag'es including the Cover Page.
• Zip the Student ID folder (Zipped folder also should be naned with Student ID number).
• Upload the zipped folder to the correct link.
Question 1
(20 marks)
This question is based on the Collection Framework and Generics.
a) You should implement an array list of Students and Lecturers and use one Generic class
called Genericperson to display elements in both array lists. Please refer the
GenericpersonDemo Test class and its execution output to fine-tune your results.
i) Corcole ae
< teim iiiated > GenchcPersonDeiiro Application]
b tudent = STD1111, Grade = 6
Student = STD2222, Grade = 7
Student = STD3333, Grade = 12
Student = STD4444, Grade = 11
Student = STD5555, Grade = 10
lecturer
Lecturer
Lecturer
Lecturer
Lecturer
(String) and grade (int) and values should be assigned through the overloaded
constnictor.
(02 marks)
®®S?6
L% iii) Implement the Iperson interface in the Student class and override the method
iv) Create a class called Lecturer and implement the two properties called
employeelD (String) and department (String) and the values should be assigned
v) Implement the Iperson interface in the Lecturer class and override the method
vi) Now create the generic class called Genericperson and implement the method
displayElements should support passing generic array list (either Lecturers array
list or Students array list). The displayElement§O method should have an iteration
and within the iteration, the each element should call the displayDetails() method
to print the Lecturer and student details as per the given output. (05 marks)
-`
Save the project as QuestionolA
b) You should create a class called AscendingTable and that should store elements as key,
value pairs. Keys should be stored according to the Ascending order. Implement the
display() method that should print keys and values according to the ascending order. Refer
the GenericDemo Test class and console output to adjust your results accordingly.
(05 marks)
8 ;prbllc cl.ae G4peericDco {
9:
publit st.rtlc `fl.ad raln{Strlng[] angs) {
AscendingTal>le<Iuteger, string> ryTal.le -B.a. ^scendlngTatllcK>( ) ;
ryTable.add(4®, -dad-);
AscendingTable.diLspLqy(tyTable);
AscendingTable.disptqy(nyTableD);
You are tasked with simulating the Producer Consumer chain in a factory. The factory uses Iron,
Wood and Cement to make their products. The raw materials are supplied by different suppliers.
Once raw materials are received it should increase the inventory and each time a product is
produced, it should reduce 1 Iron, 2 Wood and I Cement from the inventory.
Ifrawmaterialisunavailabletheproductionlineshouldbehalteduntilthesuppliesarrive.Sample
(o6 marks) L
b) Create a ProductionLine class that handles production with a rate of I product every 1000
Sample Output:
a) You are going to implement the Abstract Factory Pattern based on the scenario of
Vehicle factory that turns out Cars or Busses for the specified model. Refer the
Screenshot of the Console Output and the VehicleDemo class. You should implement
iii). Design 03 classes for Car factory called (BMW, Benz, and RollsRoys)
according to the singleton pattern. Each car should have a displayvehicleo
method you have to override.
(03 marks x 03 = 09 marks)
iv). Create Design 03 classes for Bus factory called (Volvo, Fuso, and TATA)
according to the singleton pattern. Each bus should have a displayvehicleo
method you must override. (o3 marks x o3 = 09 marks)
iEEi
b) Now design three interfaces to IBus, Icar, and VehicleFactory to override common
behaviors.
i). Now design IBus and Icar interfaces and declare the displayvehicleo
operation in each.
(01-mark x 2 = 02 marks)
Hint.. Refer to the main program and package hierarchy given below
Package Hierarchy:
e oap.eramql
> B Bagiv
> a) B-java
> a BLrfadotyjaiva
> E owactorygiva
> E| fusojarva
> ff H}usgiva
> EE ttir.jama
a RouRqysjara
E ""jara
Ea VbhickFactnygiva
E@ VEhkk"uerin
ill Vbho.jarva
CCC76
givr uestion 4 (30 marks)
You are going to control two types of satellites called Drone -Satellite and Navigational Satellite
a) You can refer to the output given in SatelliteDemo class and adjust your code
accordingly.
i) Cbnbe s3
ctefmhaeed > Satellbebemo
in nmrigational satellite activate
R8vanm mvigatlonal satellite deacti`ute
Satellite locdtion is = Sri L8nka
`:J Revae®2 dl`one satellite activate
Rar`rane02 drone satellite de®ctivate
Satellite hatioo is = Russia
i). First implement the Isatellite interface and declare activate() and deactivate()
ii). Then implement the IGeoLocation interface and declare the method called
displayLocation() (02 marks)
iii). Create two classes called I)ronesatellite and Navigationsatellite and implement
the Isatellite interface in each class and override necessary methods in each. You
should overload the constructor to pass the name of the satellite in both classes.
(4 X 2 = 08 marks)
i
CC07B
iv). SimilarlycreateaclasscalledSate]]iteLocationandimplementtheIGeoLocation
interface within the class and override the displayLocation() method. Then
overload the constructor to pass the location of the satellite. (03 marks)
b) The satellite center maintains multiple satellites and multiple Geo Location trackers. To
activate each satellite and the tracker the option can be used as a switch.
i). Create the Satellitecenter class and implement the properties option(int), and
arrayofIsatellite(Isatellite[])andthearrayofIGeoLocation(IGeoLocation[])
tracker.
(02 marks)
ii). Overload the constructor of the same class and initialize the above properties.
(03 marks)
iii). Implement the method called startservice() and you should invoke the activateo
method of the satellite class by using the option as switch. [E.g.: -if opt`i.on = 0 i/
activate Navigation satellite if option = I activate drone satellite] (02 marks)
iv). Implementthemethodcalledstopservice()andyoushouldinvokethedeactivate.()
method.
(02 marks)
v). Then develop the locationservice() method and based on the given option tracker
should invoke the displayLocation() method. (02 marks)
vi). AddanotherDronesatelliteandthetrackerintheSatellitel)emoanddisplayyour
modified output again in the console.
(03 marks)
Save the project as Question04
•E