subject

Question 16(Multiple Choice Worth 1 points) Consider the following class designed to store weather statistics at a particular date and time:

public class WeatherSnapshot
{
private int tempInFahrenheit;
private int humidity; // value of 56 means 56% humidity
private int dewPoint; // in degrees Fahrenheit
private String date; // stores the date as a String
private int time; // in military time, such as 1430 = 2:30 pm
private boolean cloudy; // true if 25% or more of the sky is covered

// constructor not shown, but it initializes all instance variables
// postcondition: returns temperature
public int getTemp()
{
return tempInFahrenheit;
}

// postcondition: returns date
public String getDate()
{
return date;
}
// postcondition: returns true if precipitation is likely; false otherwise
public boolean precipitationLikely()
{
// implementation not shown
}

// other methods not shown
}

Suppose that a client class named WeeklyWeather stores WeatherSnapshots throughout a week. This class has the following private instance variables:
private ArrayList weatherEvents;
private String startDate; // first date for the week's weather

This class needs a method that creates a subset of all WeatherSnapshot objects that match a certain date. How could this method be implemented?

Add an accessor method to the WeatherSnapshot class that returns true if the date passed as a parameter matches its date instance variable; false otherwise.

Add a method to the WeeklyWeather class that loops through its ArrayList weatherEvents, and returns an ArrayList of WeatherSnapshot objects whose dates match the date passed as a parameter.

Add a method to the WeeklyWeather class that loops through its ArrayList weatherEvents, and finds the number of WeatherSnapshot objects whose dates match the date passed as a parameter.

Add a method to the WeatherSnapshot class that returns an ArrayList of WeatherSnapshot objects that have been created whose dates match the date passed as a parameter.

Add an additional class named WeeklyWeatherSubset that contains a method that loops through the WeeklyWeather ArrayList, and returns an ArrayList of WeatherSnapshot objects whose dates match the date passed as a parameter.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:10
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 1
question
Computers and Technology, 22.06.2019 23:30
What is the digital revolution and how did it change society? what are the benefits of digital media?
Answers: 1
question
Computers and Technology, 23.06.2019 05:00
In cell b18, enter a formula to calculate the amount budgeted for meals. this amount is based on the daily meal allowance and the total travel days (# of nights+1).
Answers: 1
question
Computers and Technology, 23.06.2019 07:50
Most shops require the technician to enter a starting and ending time on the repair order to track the actual time the vehicle was in the shop and closed out by the office. this time is referred to as _ time ? a. comeback b. ro c. cycle d. lead
Answers: 1
You know the right answer?
Question 16(Multiple Choice Worth 1 points) Consider the following class designed to store weather...
Questions
question
Advanced Placement (AP), 26.03.2021 09:10
question
Mathematics, 26.03.2021 09:10
question
Mathematics, 26.03.2021 09:10
question
Mathematics, 26.03.2021 09:10
question
Mathematics, 26.03.2021 09:10
question
History, 26.03.2021 09:10
question
Mathematics, 26.03.2021 09:10
Questions on the website: 13722367