Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You are to create a Sensor class that implements the Comparable interface. Your compare should allow the user to return an alphabetic list of the

You are to create a Sensor class that implements the Comparable interface. Your compare should allow the user to return an alphabetic list of the sensors in the home. The Sensor class matches the data in the sensors.csv and it will have the following fields/columns:

PANID each sensor device in a wireless smart home network is assigned a Personal Area Network ID. In small wireless sensor networks this is a 16 bit address (00000-65536).

Type String default motion

Current Age How old is the sensor. It must be greater than 0 and less than 10,000. Default is 30.

Replacement How many days the sensor should last before it must be replaced or its power source must be re-evaluated. Must be greater than 0 and less than 15,000. Default is 500.

Complex Is this sensor very complex such that will use a lot of energy and need expensive repair. (TRUE or FALSE) Default is FALSE.

Days in Home How many days has the sensor been in the home. Must be 0 or greater and less than 1000. Default is 0.

If an invalid parameter is in the file for a particular field, you should throw a SensorNotValidException with a message telling the user why the sensor was not acceptable. An example is a non-numeric entry for one of the numeric fields. You will have to create the SensorNotValidException.

Methods

Getters and setters for each instance variable

A no argument constructor

A constructor taking each instance variable as a parameter.

A constructor taking a single String that corresponds to lines in the file may be helpful.

toString() You must report all of the instance variables in this class. You should format size to display 2 decimal places.

Any other application methods you need for your Sensor implementation.

Create a Smarthome class. The Smarthome class must contain the following.

Instance variables

A Linked List of Sensor. You must implement this using a LinkedList.

Methods

addSensor Adds a new Sensor to the Smarthome

nextDay()

nextDay must include an iterator to step through the entire list of Sensors.

If the sensor is still active, add 1 to daysInHome and currentAge for this sensor.

If the sensor is complex

Every 30 days, add 10 days to its Replacement

If the sensor is not complex,

Every 30 days, add 1 day to its Replacement

getAllSensor returns the list of sensors in an ArrayList. Must use an iterator to build the list.

Any other methods you feel necessary for your implementation

SensorNotValidException

Create a new exception to use in your program to carry meaningful messages to the user

SmarthomeTester

main method

Open and read the data contained in sensors.csv. This must be used to create sensors to populate the Smarthome. Your file reading must be done in the SmarthomeTester. You can either create a new Sensor object and pass it to the Smarthome addSensor method or you can pass the String and handle it in the appropriate class, Smarthome and/or Sensor. When you add a new sensor, set number of days in the home to 0.

Once the Smarthome has been populated, you must loop through 730 days of operation.

No sensor can exceed its Replacement Age value.

i.Once a sensor reaches Replacement age it will simply not age anymore nor is it useful.

You must report to the user the results of this operation.

Using your Comparable portion of the Sensor class, sort the sensors and display them in alphabetic order.

Finally save the results of your smarthome app back to the file specified by your user.

Your program must use a linked list to store and manipulate your sensor. Your home will simulate running for 730 days.

Sample program execution (The following is an example of the first 9 records in the sensors.csv file. The first record is empty and generates the 3 not valid messages as does the last record which sensor is out of date. NOTE: You could be given a sensor that needs to be re-calibrated and sensor data that is invalid.

Please enter the file you want to read

sensors.csv

ID

Current Age is not valid

Max Age is not valid

Days in home is not valid

ID 00071 air temperature. This sensor is currently 401.

The maximum age for this type of sensor is 1000.

This sensor is not complex.

This sensor was in the home for 30 days.

ID 00081 water temperature. This sensor is currently 401.

The maximum age for this type of sensor is 10000.

This sensor is not complex.

This sensor was in the home for 30 days.

ID 00091 video camera. This sensor is currently 530.

The maximum age for this type of sensor is 1000.

This sensor is complex.

This sensor was in the home for 90 days.

ID 00092 video camera. This sensor is currently 500.

The maximum age for this type of sensor is 1000.

This sensor is complex.

This sensor was in the home for 10 days.

ID 00093 video camera. This sensor is currently 500.

The maximum age for this type of sensor is 1000.

This sensor is complex.

This sensor was in the home for 10 days.

ID 00061 carpad pressure. This sensor is currently 301.

The maximum age for this type of sensor is 5000.

This sensor is not complex.

This sensor was in the home for 30 days.

ID 00010 voice controller. This sensor is currently 180.

The maximum age for this type of sensor is 2000.

This sensor is complex.

This sensor was in the home for 90 days.

ID 00001 analog camera.

Current Age is not valid

Max Age is not valid

Days in home is not valid

sensors.csv

00071,air temperature,400,1000,FALSE,30 00081,water temperature,400,10000,FALSE,30 00091,video camera,500,1000,TRUE,90 00092,video camera,500,1000,TRUE,10 00093,video camera,500,1000,TRUE,10 00061,carpad pressure,300,5000,FALSE,30 00010,voice controller,150,2000,TRUE,90 00001,analog camera,480,500,TRUE,90 00021,motion,30,500,FALSE,60 00022,motion,30,500,FALSE,60 00023,motion,30,500,FALSE,60 00031,tripped switch,200,5000,FALSE,60 00032,tripped switch,200,5000,FALSE,60 00033,tripped switch,200,5000,FALSE,60 00034,tripped switch,200,5000,FALSE,60 00100,still camera,200,5000,TRUE,10 00110,doorbell camera,CurAge,1000,TRUE,10 00041,appliance detection,100,MaxAge,TRUE,30 00120,interactive mirror,10,1000,TRUE,X 00051,smoke detection,10,1000,yes,30

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago