The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
Your task is to write a program that will store weather data based on location of the
reading. To complete this task, we will use a custom data model and implement the
Observer and Adapter design patterns. Refer to the included driver for questions on
class and method names used.
1. 2. 3. Custom Data Model
a.i) Create a data interface that will define only getters for Location(String),
Time(Calendar), Temperature(double), Barometric Pressure(double),
Humidity(double), and Wind Speed(double). Location will be based on Zip
Code which may have a dash, so use String for this.
(1 interface-WeatherDataInterface)
a.ii)Create a class that will store this data interface in a Map with the location as
the key and a sorted set of the data interface as the value.
* Constructor will take a Comparator parameter
* get the most recent data object based on the location as a parametergetCurrentWeather
* add data object with the data interface as a parameter-add
(1 class-WeatherDataManager)
a.iii)
For sorting, create a comparator class that implements the Comparator
Interface and base the comparison on time. This will be used when creating
the sorted set.
(1 class-CalendarComparator)
Observer Pattern
a.i) Create custom listener interface for added data only with the method:
weatherDataModified.
(1 interface-WeatherDataListenerInterface)
a.ii)Create a custom Event class to be used for the added. The added data event
will push the added data object out with the method: getData.
(1 class-WeatherDataEvent)
Incorporate this into the custom data manager and fire events for the add and
remove methods.
Adapter Pattern
A data class from a customer will be used that contains Location(int), Time(Date),
Temperature(double), Humidity(double), and Wind Velocity(double) (note the different
name, data type, and missing elements).
a.i) Write a Data Class that will represent this data with appropriate constructor
for setting the data and getters for the data.
(1 class-ExternalWeatherData)
a.ii)Write an adapter class that will translate the data from the external data
object to your data interface. Return 0 for any missing data elements and
convert data as needed.
(1 class-ExternalWeatherDataAdapter)
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly