Programming Assignment
Create a class called WeatherData that will store information about daily weather conditions for NASA. It should be able to store the current daily temperature as well as wind speed. You also want to use good object-oriented programming (OOP) practices and ensure that the WeatherData class contains the following methods:
Default constructor: WeatherData()
Overloaded constructor: WeatherData(double dailyTemp, int windSpeed)
Mutators / set methods: void setDailyTemp(double newTemp), void setWindSpeed(int newWindSpeed)
Accessors / get methods: double getDailyTemp(), int getWindSpeed()
String method that returns a description of all class data as a string: String toString()
Equals method that can compare WeatherData objects: boolean equals(Object obj)
Ensure that the WeatherData class is stored in a file called WeatherData.java. Then create another class called Test (within the same project) that contains the main() method with the following test code:
WeatherData day1 = new WeatherData();
// Next two lines will test the set() methods
day1.setDailyTemp(75.0);
day1.setWindSpeed(100);
// This next line tests the toString() method in WeatherData for Day1
System.out.println(Day1-> + day1);
WeatherData day2 = new WeatherData(52.0, 10);
// This next line tests the toString() method in WeatherData for Day2
System.out.println(Day2-> + day2);
// This next line will test the equals() method in WeatherData with two different objects
if(day1 == day2)
System.out.println(Day1 is equal to Day2);
else
System.out.println(Day1 is NOT equal to Day2);
// This next line will test the equals() method in WeatherData with two equal objects
WeatherData day3 = new WeatherData(75.0, 100);
if(day1 == day3)
System.out.println(Day1 is equal to Day3);
else
System.out.println(Day1 is NOT equal to Day3);
// The next two lines will test the get() methods of the WeatherData class.
System.out.println(Day2 Daily Temperature: + day2.getDailyTemp());
System.out.println(Day3 Wind Speed: + day3.getWindSpeed());
Ensure that the test class is stored in a file called Test.java. When you run the Test application, the output should be as follows:
Day1->Weather Data: Daily Temperature = 75.0 F. Wind Speed = 100 mph.
Day2->Weather Data: Daily Temperature = 52.0 F. Wind Speed = 10 mph.
Day1 is NOT equal to Day2
Day1 is equal to Day3
Day2 Daily Temperature: 52.0
Day3 WindSpeed: 100
Also ensure that the following requirements are met:
1) Java file is named correctly.
2) Name, date and assignment information is included at the top of your Java code file as a comment.
3) Java code is properly indented and readable.
4) Javadoc style comments are present above each class and method name.
5) Output is formatted correctly and meets the requirements above.
Once you verify that your program runs correctly and you have met the requirements, create a Word or PDF document with the following:
1) Your name, date and assignment identification at the top of the page (Ex. CIS-210 Week 7 Programming Assignment)
2) Full Java source code listing
3) Screenshot of the code compiling successfully in the IDE with the timestamp showing.
4) Screenshot of the code running showing the correct output under all test conditions.
Archive (zip) the results document and the actual .java code files into a single zip file and submit through the classroom. Please name the zip file with
Last Completed Projects
| topic title | academic level | Writer | delivered |
|---|
