This assignment is designed to help you think about where data and computations belong in a well-designed object-oriented program. Methods that produces the right answer, but aren't structured well, won't earn you many points. Figuring out where to put the various pieces of data, and what methods you need to create to work with them, are part of the what you are being asked to figure out.
WeatherMonitor
class with (at least these) two methods:
averageHighForMonth
, which takes a month (designated by a number such as 1 for January, 2 for February, etc) and a year and produces the average high temperature over all days that month.*
averageLowForMonth
, which takes a month (designated by a number such as 1 for January, 2 for February, etc) and a year and produces the average low temperature over all days that month.*
To manage the daily weather data, your WeatherMonitor
must also provide a method addDailyReport
that consumes a date and a list of readings (nominally for that date) and stores a daily report for the given date (computing the high and low temperature readings from the given list of readings for that date).
(* We won't actually require you to provide examples of daily weather reports for every single day in a month. Your calculations of averageHighForMonth
and averageLowForMonth
should produce the averages over all days in
the month for which there are daily weather reports.)
questions.txt
. You do not turn in separate code for these exercises: just modify your existing code as needed to meet these goals.
Thinking ahead, you know that the weather monitor program should be able to support different data structures for the daily weather reports. Edit your code as needed to encapsulate the type of the daily weather reports from the overall WeatherMonitor
class. In questions.txt
, explain what specifically in your code would achieve this goal. As part of your answer, explain where (which lines/expressions) someone would have to change in order to use a spanking new "weatherGlob" data structure instead of your current LinkedList implementation. (Note: you are NOT being asked to implement weatherGlob. Just assume such a class exists and tell us how someone would plug it into your code.)
The weather watchdog group that uses your Weather Monitor has an activist staff member who wants to find evidence of global warming, and is willing to alter weather data slightly to help his cause. The activist has access to a
WeatherMonitor
object. Edit your code as needed to guarantee that the staff member cannot change any of the daily weather reports or their readings. In questions.txt
, explain what specifically in your code achieves this goal.
Look at the code you have now: are there any aspects of it that you would like to clean up, but don't yet know how in Java? Are you satisfied with your code from a design standpoint? Provide answers to these questions in questions.txt
.
Programs must compile in order to receive credit. Programs must run in order to receive credit for Examples and Test Cases. Code that is commented out will not be graded.
Using web-based turnin,
submit .java files (as a .zip file) containing the final versions of all classes, interfaces, and examples developed for this assignment. Your .zip file should also contain the answers to the questions in the file questions.txt
. Do not submit the .class files.