java basic codes

java basic codes

Define an abstract class named Temperature that stores a single temperature (as an integer value). The class should contain the following:

  • An integer variable for storing the temperature
  • An alternator constructor, passed a temperature value
  • A single getter method
  • An abstract toString method
  • An abstract method belowFreezing (that returns true if the temperature is below freezing or not)
  • An abstract method swimmingWeather (that returns true if the temperature is warm enough to go swimming)
    Define a subclass of the Temperature class named Fahrenheit, containing the following:
  • An alternator constructor, passed a temperature value (making a call to its parent constructor)
  • An implementation of the toString method to return a string of the form “76 degrees Fahrenheit”
  • An implementation of method belowFreezing (to return true if the temperature is less than 32 degrees)
  • An implementation of method swimmingWeather (to return true if the temperature is greater than or equal to 80 degrees)
  • An implementation of method convertToCelsius that returns the temperature in degree Celsius (as a floating point value) Define a subclass of the Temperature class named Celsius, containing the following:
  • An alternator constructor, passed a temperature value (making a call to its parent constructor)
  • An implementation of the toString method to return a string of the form “76 degrees Celsius”
  • An implementation of method belowFreezing (to return true if the temperature is less than 0 degrees)
  • An implementation of method swimmingWeather (to return true if the temperature is greater than or equal to 27 degrees)
  • An implementation of method convertToFahrenheit that returns the temperature in degree Fahrenheit (as a floating point value) Finally, develop and appropriate test driver for the Fahrenheit and Celsius classes.