JMU
logo.png
Programming Assignment 1


1 Overview: As you know, some students find it difficult/inconvenient to attend lectures. We are going to capitalize on this situation by selling a product called VirtualStudent that will enable students to record the lectures they don't attend.
2 Existing Components: Several classes have already been developed:

3 New Components: You must develop the following class:
VSDriver ( SRS )
4 Getting Started: Before you even start thinking about programming, make sure that you understand the problem. Specifically, make sure you:
  1. Understand the capabilities of the existing classes.
  2. Understand the software requirement specification (SRS) for the application.
  3. Understand which objects should perform error checking. In particular, note that much of the required error checking can and should be handled by the ScheduledTime, Event and Schedule classes.
5 A Suggested Implementation/Testing Process: As always, you should divide the implementation and testing phase into small pieces and work on one piece at a time. It is possible to divide-up the assignment in many different ways; one possible approach is described below. After each step in the process, you should completely test your code.
  1. Create a VSDriver class that has all of the String "constants" you'll need for the application (e.g., for prompts and error messages), and an empty method with the signature public static void main(String[] args).
  2. Add code to the main() method that: calls the ScheduledTime class's setTruncationValue() method passing it the value 5, declares and constructs a Schedule object, and adds several hard-coded Event objects to it. (It's a good idea to try and construct some Event objects with invalid days or times to see what happens.)
  3. Add a method with the signature private static void displayEvents(Schedule schedule) that outputs the given Schedule object in the appropriate format. Modify the main() method so that it calls the displayEvents() method both before and after the Event objects are added to the Schedule object.
  4. Experiment with different "truncation values" and make sure you understand what happens.
  5. Add a method with the signature private static boolean addEvent(Event event, Schedule schedule) that adds the given Event to the given Schedule object only if it does not conflict with (i.e., overlap) an Event that is in the Schedule. This method should return true if the Event was added and false otherwise. Modify the main() method so that it uses the addEvent() method.
  6. Add a method with the signature private static Event createEvent(String s) that parses the given String representation of an Event, constructs a corresponding Event object, and returns it. If the String representation can't be parsed, this method should output the appropriate error message and return null. Modify the main() method so that it uses the createEvent() method.
  7. Modify the main() method so that the application provides the required functionality.
  8. Look for duplicative code in the main() method and add methods that eliminate the duplication.

Copyright 2011