1) Implement converter class hierarchy as follows: a. Converter class which includes: Private attribute for input of data type double Default constructor with no parameter which sets input to Double.NaN Overloaded constructor with input for parameter Get and set methods for input attribute Method convert() which returns input value b. TemperatureConverter class which is a child of Converter and includes: Constructors which call parent constructors Overridden convert() method to convert input (Fahrenheit temperature) to Celsius and returns the value. If the instance has no input value, it should return Double.NaN Use the following formula for conversion: C = ((F-32)*5)/9 c. DistanceConverter class which is a child of Converter and includes: Constructors which call parent constructors Overridden convert() method to convert input (distance in miles) to distance in kilometers and returns the value. If the instance has no input value, it should return Double.NaN d. Use the following formula for conversion: KM = M * 1.609 2) Implement GUIConverter class using JFrame and JPanel as follows: a. GUI will have 3 buttons: “Distance Converter”, “Temperature Converter”, and “Exit”.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
1) Implement converter class hierarchy as follows:
a. Converter class which includes:
Private attribute for input of data type double
Default constructor with no parameter which sets input to Double.NaN
Overloaded constructor with input for parameter
Get and set methods for input attribute
Method convert() which returns input value
b. TemperatureConverter class which is a child of Converter and includes:
Constructors which call parent constructors
Overridden convert() method to convert input (Fahrenheit temperature) to
Celsius and returns the value. If the instance has no input value, it should
return Double.NaN
Use the following formula for conversion: C = ((F-32)*5)/9
c. DistanceConverter class which is a child of Converter and includes:
Constructors which call parent constructors
Overridden convert() method to convert input (distance in miles) to distance
in kilometers and returns the value. If the instance has no input value, it
should return Double.NaN
d. Use the following formula for conversion: KM = M * 1.609
2) Implement GUIConverter class using JFrame and JPanel as follows:
a. GUI will have 3 buttons: “Distance Converter”, “Temperature Converter”, and
“Exit”.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 1 images