Java greenhousecontroller read from file help!

Discussion in 'Software' started by EmptyVoid, Mar 28, 2005.

  1. EmptyVoid

    EmptyVoid Private E-2

    Hi, I'm having trouble with this assignment. I haven't learned this stuff yet and not sure what to do. Any help would be appreciated.

    This is what I have been told to do:

    Quote:
    Your starting point of this assignment are the GreenhouseControls.java, Events.java. and Controller.java in the programs/c08 and programs/c08/controller directories in the ICS4M handout drive. You are going to modify these programs to show you the various ways you can build on the basic design model using the capabilities of Java. The assignment is divided into three parts to help you organize your programming efforts. The intermediate stages serve as checkpoints for you, you submit only the final program.

    Part 2

    In this part, you will modify the program to read the events from a file.

    Modify Restart() to start the system by reading in the system state from a file specified on the command line:

    java GreenHouseControls -f examples.txt

    The -f argument must be present. It serves no pupose in this assignment but is needed in a future assignemtn. The even information must be in the format specified like this:


    addEvent (new Bell (tm + 9000));
    addEvent (new ThermostatNight (tm));
    addEvent (new LightOn (tm + 1000));
    addEvent (new WaterOn (tm + 3000));
    rings = 5;
    addEvent (new FansOn (tm + 4000));
    addEvent (new LightOff (tm + 2000));
    addEvent (new FansOff (tm + 6000));
    addEvent (new WaterOff (tm + 8000));
    addEvent (new ThermostatDay (tm + 10000));

    To simplify testing, you can assume a maximum of 20 events and at least 500 msec between events. If a line of data is incorrectly formatted or for an unknown event please print the line with an appropriate error message, then continue with the next line.

    After reading, Events must be stored in the EventSet according to the time they are to occur. Assume that no time number is more than 8 digits long. Restart() must be able to deal appropriately with any order of the Events. To accomplish this have Restart() save the relevant Event information in an LinkedList of strings and sort the Events by time before adding each events to EventSet. Use the <list>.add() to set up your linked list. This is shown in c09:List1.java and Collections.sort(<list>) shown in c09:ListSortSearch.Modify the Bell() to output a single "Bing!". When you read in a Bell event generate the appropriate number of Bell events as indicated by rings. These must be set to correct times. This is an alternative to generating the new Bell events within Bell(). It will allow them be sorted into their correct time sequence. At this point the output of the program should be identical the original program.

    After the initial start, when restarting Restart() must provide to the user the option to recreate the EventSet from the linked list or read in a new file(supplied by the user). This must be achieved by prompting the user at the console. Please also allow the user the option to quit the program at this stage.

    Part 3

    In this part yo use a different data structure to simplify the Controller.java code.

    In Controller.java, change the code to use a stack instead of an EventSet. Please see c09:StackL.java for an example of how to implement the stack functionality using a linked list. You will need to reverse the sort order to use the stack. Please see c09:Reverse.java for an example that uses a sort comparatore to reverse the natural sort order.


    I'm having trouble uploading, but if anyone could tell how to read events from a file would be helpful.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds