0% found this document useful (0 votes)
5 views1 page

Object-Oriented Programming Exercise

The document outlines an exercise for an Object Oriented Programming course at the Lebanese University, focusing on implementing various classes and interfaces based on a provided UML diagram. It requires the implementation of an interface, an abstract class, and several concrete classes, including Computer and USB, with specific attributes and methods. Additionally, it includes instructions for creating a TechShop and displaying alternative computers based on certain criteria.

Uploaded by

Rayyan Mostapha
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)
5 views1 page

Object-Oriented Programming Exercise

The document outlines an exercise for an Object Oriented Programming course at the Lebanese University, focusing on implementing various classes and interfaces based on a provided UML diagram. It requires the implementation of an interface, an abstract class, and several concrete classes, including Computer and USB, with specific attributes and methods. Additionally, it includes instructions for creating a TechShop and displaying alternative computers based on certain criteria.

Uploaded by

Rayyan Mostapha
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

Lebanese University

Faculty of Sciences – section 5

I2211 – Object Oriented Programming

Exercise 3
Consider the following UML diagram:

1. Implement the interface Alternative.


2. Implement the abstract class Device. Note the following:
• The price is expressed in dollars and its values should be strictly greater than zero.
• The toString method returns a String of the form “Brand: …. Price: …. dollars”.
3. Implement the class Computer. The “type” attribute indicates whether the computer is a desktop,
laptop, workstation, etc. Note that two computers are alternatives if they have the same type and the
same cpu.
4. Implement the class USB. Two USB are alternatives if they have the save storage amount.
5. Implement the class TechShop.
6. Assume having a test class with a main method that creates a TechShop called “Modern Tech”:

public static void main(String[] args) {


TechShop tShop = new TechShop("Modern Tech");
// We added many devices to tShop …..

Computer computer1 = new Computer("laptop", "core i7", "hp", 650);


...
}

Assume that we added many devices to the TechShop (tShop object). Complete the main method in
order to display all the computers in the tShop that could be alternative to computer1 (object already
created in the main method above).
Page 1/1

You might also like