OOP - Final - LAB - Exam II A-B - Iqra Shahzad
OOP - Final - LAB - Exam II A-B - Iqra Shahzad
_________________
[10 Marks]
Develop a java code for creating a class named Trigon inherited from the class
GeometricShape (containing a single data member named shapeName (a string) and a member
function named setShapeName(shapeName).
The class Trigon is required to hold:
1. Three data members i.e. base, perpendicular, and hypotenuse of type double
2. A no-arg constructor that initializes all data members with value 1.0
3. A parameterized constructor to initialize all data fields with user-defined values
4. The setter functions for all three data fields
5. The getter functions for all three data fields
6. A function named displayArea() (0.5*(perpendicular x base))that shows the area of a certain
Trigon object.
In the main() Class make three objects of class Trigon while considering the shapeName as
“triangle” for each object. In addition, it is required to invoke all the functions of Trigon class.
[10 Marks]
Develop a Java code for interfaces and demonstrate their usage in the context of a music streaming service.
It has additional methods such as download (), createPlaylist (), and sharePlaylist ().
Implement a class PremiumPlayer that implements both Music and PremiumMusic interfaces.
Create instances of both BasicPlayer and PremiumPlayer. Implemented methods perform appropriate actions
or output messages to display the functionality of a music streaming service from both interfaces.
Page 1 of 2
Music interface methods should display (for.eg. music is playing, pausing or stopped).
PremiumMusic interface methods should display (for. e.g., downloading, creating playlists, sharing playlists).
Develop the Java program to implement GUI given in Figure 1 by using AWT/Swing classes.
Above interface is Java GUI application to convert miles to kilometers when pressing the
"Convert!" button.
Note that 1 mile is equal to 1.609 kilometers.
Page 2 of 2