Fiza Oop 9
Fiza Oop 9
Karachi Campus
Submitted By:
Submitted To:
3 A company manages many stores. Each Store contains many Products. Implement
Product, Store and Company classes using association and aggregation concepts
and design UML class diagram.
Submitted On:
9/5/2024
(Date: DD/MM/YY)
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
LAB # 09
Task # 01:
Write a program and create the objects of classes in class car to explain the concept of composition. Create
several classes as engine, doors, capacity and wheel having their individual methods attributes. The object
of these classes are created in a car class and they are set as public. The object of this car class is created
in Main method and this with the help of this object we can call other classes as well and can use their
functionalities and design UML class diagram
Solution:
Main class:
package fizalab9_task1;
Car class:
package fizalab9_task1;
FIZA KHAN 1
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
this.speed=speed;
}
Engine class:
package fizalab9_task1;
Doors class:
package fizalab9_task1;
FIZA KHAN 2
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
Capacity class:
package fizalab9_task1;
Wheels class:
package fizalab9_task1;
FIZA KHAN 3
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
Output:
UML:
Task # 03:
A company manages many stores. Each Store contains many Products. Implement Product, Store and
Company classes using association and aggrigation concepts and design UML class diagram.
FIZA KHAN 4
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
Task # 03:
A company manages many stores. Each Store contains many Products. Implement Product, Store and
Company classes using association and aggrigation concepts and design UML class diagram.
Solution:
Main class:
package fizalab9_task3;
import java.util.*;
FIZA KHAN 5
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
Product class:
package fizalab9_task3;
Store class:
package fizalab9_task3;
import java.util.List;
FIZA KHAN 6
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
this.name = name;
this.loc = loc;
this.owner = owner;
this.products = products;
}
Company class:
package fizalab9_task3;
import java.util.*;
public class Company {
private String name;
private double revenue;
private List<Store> stores;
FIZA KHAN 7
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
Output:
FIZA KHAN 8
3/5/2024 Object Oriented Programming
[Association , Aggregation and Composition]
UML:
FIZA KHAN 9