- StudyBlue
- Michigan
- University of Michigan - Ann Arbor
- Computer Science
- Computer Science 481
- Chesney
- Homework 3 - Complete.pdf
Homework 3 - Complete.pdf
Computer Science 481 with Chesney at University of Michigan - Ann Arbor
About this note
By: Arun Ganesan
Textbook:
Software Engineering: A Practitioner's Approach
Created: 2008-06-09
File Size: 5 page(s)
Views: 4
Textbook:
Software Engineering: A Practitioner's ApproachCreated: 2008-06-09
File Size: 5 page(s)
Views: 4
About StudyBlue
STUDYBLUE makes things that make you better at school.
Things like online flashcards with photos and audio.
Things like personalized quizzes and friendly reminders about when (and what) to study next.
Think of it as a digital backpack™: access to all of your study materials online and on your phone.
STUDYBLUE exists to make studying efficient and effective for every student, for free. Join us.
“I have been getting MUCH better grades on all my tests for school. Flash cards, notes, and quizzes are great on here. Thanks!”
Kathy
Kathy
Sign up (free) to study this.
Homework 3 EECS 481 Fall 2005 Due: 1:45pm, Thursday 10 th November, hardcopy, in-class Note: Because some of the common modeling tools do not support some UML diagram types very well, it is acceptable for you to NEATLY hand-draw any ONE type of diagram. For example, Visio does not do a good job with State Chart Diagrams, so you may decide to hand-draw those for both questions that require them. But you may NOT hand-draw one type of diagram for one question and a different type for another question. If your modeling tool ?almost? supports the diagram you want, you may print the diagram using the tool and then NEATLY correct it by hand. CLASS DIAGRAM (10 points) Q.1. RiverNile.com sells books, CDs, and downloadable songs online, and operates a system for customers to find items and place orders that uses the information described below. Using Visio or another modeling tool, create a class diagram using proper UML notation for the domain data used by this system. You should show relationships between classes and all attributes mentioned in the description of the data, but you do NOT need to include any operations. (You should, however, use the proper notation for a class that might include both attributes and operations.) You do not need to show any ?supporting? classes, such as user interface classes or ?controller? classes ? just show the classes representing the data described here. For attribute data types, use String, Date, Time, int and float. Each order is for a single customer, and each order may have any number of items. Each item on an order may be ordered in any quantity. The price of an item on an order is set at the time the order is created, so that subsequent price changes on the item will not affect existing orders. Customer information, including a name and telephone number, is kept separately from orders so that customers do not need to enter their information every time they order. A customer must have at least a billing address, and may optionally have a second shipping address. An address consists of a street name and number (a single String), a city, state and zip code. An item may be a book, a CD, or a downloadable song. All items have a price and release date. Each book has a title, author, publisher, and number of pages. Each CD has a title and artist name, as well as the list of songs included. Each song (both songs on CDs and downloadable songs for sale) has a title and length (running time). Every song is on exactly one CD (this is not realistic, but has implications for your model). SEQUENCE DIAGRAM (10 points) Q.2. Using Visio or another modeling tool, create a sequence diagram using proper UML notation that represents the process described below to read and print lines from a file. As the top-level controlling object in your sequence diagram, you may use an unnamed object of type MyPgm. For details about the classes and operations used, see the code fragments below that present the public class interfaces. When MyPgm starts this scenario, it already has a String name that identifies a file. Your MyPgm object should begin by creating a File object and then opening the File. If the open succeeds, create a FileBuffer for the File, and then create an InputStream for the FileBuffer. Get the number of lines in the File using getNumberOfLines() on the File. Now in a loop that runs as many times as there are lines in the file, call readLine() on the InputStream and print the result String using StandardOutput's printLine() function. Each time readLine() is called on the InputStream, the InputStream must call readByte() on the FileBuffer until a newline character is encountered. For each call to readByte(), the FileBuffer checks to see if its buffer has been exhausted, and if so it calls readNextBlock() on its File to fill the buffer. Then it returns the next byte in the buffer. class File { public: // Create a new File object // for the file identified // by the name passed in. File(String name); // Open the file identified // by name, and return true // if the open succeeds, // and false otherwise bool open(); // Return the number of //lines in the file int getNumberOfLines(); // Read the next file block // from disk, and return // the contents CharArray readNextBlock(); } class StandardOutput { public: // Print str printLine(String str); } class FileBuffer { public: // Create a new FileBuffer // to read from File f. // File f must already be // open when this // constructor is called. FileBuffer(File f); // Return the next byte // from this buffer. If // buffer exhausted, call // readNextBlock() on File. char readByte(); } class InputStream { public: // Create an InputStream to // read lines from a // FileBuffer InputStream(FileBuffer b); // Call readByte() on a // FileBuffer until a // newline character // is read, and return // the chars read as a // String. String readLine(); } STATE CHART DIAGRAM (10 points) Q.3. Using Visio or another modeling tool, create a state chart diagram using proper UML notation for a VCR that operates as described below. Your state chart diagram should exhibit at least one level of nested states. The VCR has the following buttons: "Power", "Rewind", "Fast Forward", "Stop", "Play", and "Record". The "Power" button turns the VCR on and off, and it can only be turned off when it is stopped (the "Power" button has no effect when the VCR is running). When the VCR is stopped (not currently playing or recording), the "Rewind" and "Fast Forward" buttons can be used to quickly rewind or advance the tape. When it is playing, "Rewind" toggles between playing the tape backwards at single speed and double speed, while "Fast Forward" always plays the tape forward at double speed. The "Play" button returns the tape to playing at normal speed. When the VCR is recording, no buttons have any effect except for "Stop". When the VCR is playing, the "Record" button has no effect. KITCHEN TIMER DESIGN (20 points) Q.4. For this question, you will create a UML model for a kitchen timer. Using proper UML notation and a modeling tool such as Visio, you must create a Class Diagram and State Chart Diagram for the system, and a Sequence Diagram that models the scenario described below. Along with your Class Diagram, you must also clearly describe each operation in your classes. (One or two sentences should be enough, and if you define any getters or setters that simply access members, you do not need to describe those.) You must use the TimeCounter class and the TimeListener interface (abstract class) described below in your system. This forces you to adopt the common design practice of separating the user interface class(es) of your system from the ?domain? classes of the system. The TimeCounter can count down from a time value to zero, and will call the updateTime(Time t) function in each of its TimeListeners every second. You SHOULD include the TimeCounter and TimeListener classes in your class diagram, including their public operations described below. You do NOT need to include the Time class ? you may treat Time as though it is a ?primitive? data type in this system. Timer System Description The timer displays a time value with minutes and seconds, and when it is running it counts down one second at a time. When it runs down to zero, an alarm sounds and the timer stops. The timer has four buttons, labeled Min+, Min-, Start/Stop, and Clear that operate as follows: ? ?Min+? adds a minute to the time displayed, and may be used whether the timer is running or stopped. If the timer is running, a minute is added and the timer keeps running. ? ?Min-? subtracts a minute from the time displayed, and may be used whether the timer is running or stopped. If ?Min-? is pressed with less than a minute showing on the timer, the displayed time is changed to zero. If the timer is running and ?Min-? sets the time to zero, the timer stops but the alarm does NOT sound. ? ?Start/Stop? starts the timer if it is currently stopped and has a non-zero time displayed. ?Start/Stop? stops the timer if it is currently running. ?Start/Stop? has no effect when the timer is stopped with zero displayed. ? ?Clear? sets the displayed time to zero if the timer is stopped, but has no effect if the timer is running. Scenario for Your Sequence Diagram This scenario begins with the timer cleared and stopped. 1. The user presses the ?Min+? button 3 times to set the timer to 3:00 (3 minutes and no seconds). 2. The user presses the ?Start/Stop? button to start the timer. 3. The timer counts down, updating its display of time remaining every second. 4. When the timer reaches zero, the alarm sounds. The scenario ends with the timer cleared (showing no time) and stopped. Q.4. (Continued from previous page) TimeCounter and TimeListener Classes You MUST Use TimeListener is an interface (an abstract class) that you can subclass. It contains a single abstract operation: updateTime(Time t). By implementing this operation, your subclass can respond to changes in the Time value generated by the TimeKeeper. TimeCounter is a class that counts down from a time you may set or change. It has these operations: ? void addListener(TimeListener listener) ? add the listener so that this TimeCounter will call the listener?s updateTime operation each second. ? Time getTime( ) ? returns the current Time value of this TimeCounter. ? void addMinute( ) ? add one minute to the time from which this TimeCounter counts down. If a countdown is in progress, it remains in progress. ? void subMinute( ) ? subtract one minute from the time from which this TimeCounter counts down. If a countdown is in progress, it remains in progress. If the current value is one minute or less, the value is set to zero and any countdown in progress stops. ? void clear( ) ? set the time to zero, and stop any count down currently in progress. ? void start( ) ? an asynchronous operation that starts a new thread of execution in which this TimeCounter counts down, calling updateTime on each of its listeners as it counts down. ? void stop( ) ? stop counting down. saads EECS 481 Fall 2004
Back
Next
About this note
By: Arun Ganesan
Textbook:
Software Engineering: A Practitioner's Approach
Created: 2008-06-09
File Size: 5 page(s)
Views: 4
Textbook:
Software Engineering: A Practitioner's ApproachCreated: 2008-06-09
File Size: 5 page(s)
Views: 4
About StudyBlue
STUDYBLUE makes things that make you better at school.
Things like online flashcards with photos and audio.
Things like personalized quizzes and friendly reminders about when (and what) to study next.
Think of it as a digital backpack™: access to all of your study materials online and on your phone.
STUDYBLUE exists to make studying efficient and effective for every student, for free. Join us.
“I have been getting MUCH better grades on all my tests for school. Flash cards, notes, and quizzes are great on here. Thanks!”
Kathy
Kathy