Iem Sheet 1copy BW
Iem Sheet 1copy BW
Question 1
Write a class Triangle, which has two member variables base of type int, and height
of type int. Write a constructor which initialises the base and the height of a Triangle
instance. Write a method getArea() that returns the area of the Triangle as a double.
Write a method show(), to print the dimensions and area of the Triangle instance.
Write a method compare(Triangle t1, Triangle t2), which determines compares the
area of two given Triangle objects (hint: recall the Float class compare() method used
in Lab #2). In the main method of the Triangle class, obtain user input for the
Triangle's base and height. If the user wishes to do a comparison, ask for the
dimensions of Triangle t1 and Triangle t2.
Code:
Output:
Implement the Equipment class from the IFCS, according to the following class
diagram:
Equipment
- id : String
- description: String
+ Equipment(id:String, desc:String)
+ getId() : String
+ getDesc() : String
Write an IFCSManager class to maintain an array of Equipment objects, sorted
according to Equipment id. (Hint: refer to Lab #2 Question 2).
The IFCSManager will
add new Equipment instances
remove an Equipment instance specified by its id
given an id, report if the Equipment instance resides in the Lab
display the list of Equipment instances in the Lab.
Code:
Output: