Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment Description Create, test, and document a Java program to have the fol

ID: 3875688 • Letter: A

Question

Assignment Description Create, test, and document a Java program to have the following classes and must meet the given specifications 1. An abstract class named Position, which stores the degree and minute of either a longitude or a . A subclass of Position named Latitude, which represents the latitude of a position. It should have · A subclass of Position named Longitude, which represents the longitude of a position. It should latitude. the extra attribute (of type String to store either “N" or “s". have the extra attribute (of type String) to store either "E" or "W". A class named Weatherlnformation to store the maximum and minimum temperature of a point on the earth. It should have attributes to store the latitude, longitude, minimum temperature ever recorded, and the maximum temperature ever recorded at that position. The maximum temperature must be more than the minimum temperature at every location. . The class Weatherlnformation must implement the following interface. public interface WeatherRecord f *Sets the maximum temperature *@param maxTemperature the new maximum temperature public void setMaxTemperature(double maxTemperature); k * *Sets the minimum temperature *@param minTemperature the new minimum temperature public void setMinTemperature(double minTemperature); » A driver that does the following: It creates 10 different Latitude objects and 10 different Longitude objects. Half of the latitudes must be north of the equator and the other half must be south of the equator. Half of the longitudes must be west of the Prime Meridian and the other half must be east of the prime meridian. It creates 10 weather records for 10 locations on earth. All of the latitudes and longitudes created above must be used in one of the records. Approximately half of the minimum temperatures must be negative. o

Explanation / Answer

/**
*
* @author manB
*/
abstract class Position {
    protected int degree;
    protected int minute;

    public Position(int degree, int minute) {
        this.degree = degree;
        this.minute = minute;
    }
  
    abstract String getPosition();
}

class Latitude extends Position {
    private String NorthOrSouth;

    public Latitude(int degree, int minute, String NorthOrSouth) {
        super(degree, minute);
        this.NorthOrSouth = NorthOrSouth;
    }
  
  
    @Override
    String getPosition() {
        return "Latitude: [" + "degree=" + degree + ",minute=" + minute + ",NorthOrSouth=" + NorthOrSouth + ']';
    }

    @Override
    public String toString() {
        return getPosition();
    }
  
}


class Longitude extends Position {
    private String eastOrWest;

    public Longitude(int degree, int minute, String eastOrWest) {
        super(degree, minute);
        this.eastOrWest = eastOrWest;
    }  
  
    @Override
    String getPosition() {
        return "Longitude: [" + "degree=" + degree + ",minute=" + minute + ",eastOrWest=" + eastOrWest + ']';
    }

    @Override
    public String toString() {
        return getPosition();
    }
  
}

interface WeatherRecord {
/**
*   Sets the maximum temperature
*   (fflparam maxTemperature the new maximum temperature
*/
public void setMaxTemperature(double maxTemperature);
/**
*   Sets the minimum temperature
*   @param minTemperature the new minimum temperature
*
*/

public void setMinTemperature(double minTemperature);
}

public class WeatherInformation implements WeatherRecord{
    private double maxTemperature;
    private double minTemperature;
    private Longitude longitude;
    private Latitude latitude;

    public WeatherInformation(Latitude latitude, Longitude longitude, double minTemperature, double maxTemperature) {
        if (maxTemperature < minTemperature)
            throw new IllegalArgumentException("Maximum Teperature is lower than minimum temperature");
        this.maxTemperature = maxTemperature;
        this.minTemperature = minTemperature;
        this.longitude = longitude;
        this.latitude = latitude;
    }
  
  
    @Override
    public void setMaxTemperature(double maxTemperature) {
        if (maxTemperature > minTemperature)
            this.maxTemperature = maxTemperature;
        else
            throw new IllegalArgumentException("Max temperature not more than minimum temperature");
    }

    @Override
    public void setMinTemperature(double minTemperature) {
        if (maxTemperature > minTemperature)
            this.minTemperature = minTemperature;
        else
            throw new IllegalArgumentException("Min temperature not less than maximum temperature");
    }

    @Override
    public String toString() {
        return "WeatherInformation[" + "latitude=" + latitude + ", longitude=" + longitude + ", minTemperature=" + minTemperature + ", maxTemperature=" + maxTemperature + '}';
    }
  
}

class WeatherInformationTester {
    public static void main(String[] args) {
        WeatherInformation weatherInformation = new WeatherInformation(new Latitude(25, 5, "N"), new Longitude(92, 22, "E"), 25, 32);
        System.out.println(weatherInformation);
    }
}

I have provided 1 sample test case. You should add more 9. If you face any trouble, please let me know

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote