{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

SKELETON_6

# SKELETON_6 - CS 31 Introduction to Computer Science I UCLA...

This preview shows pages 1–3. Sign up to view the full content.

CS 31: Introduction to Computer Science I: Winter 2010: Project 6 Skeleton Page 1 // UCLA Winter 2010 // CS 31 Project 6: Object Oriented Tape Player: Skeleton Code // John A. Rohr // March 2, 2010 // // // This program simulates the operation of a tape player. // // The tape player has three states: stopped, moving forward, and moving backward. // When the tape is moving, it can be moving at the play speed, faster, or slower. // // The tape player includes the transport mechanism that holds the tape reels, // function buttons to control the operation, and a display to show the status // of the player at each increment of time. // // At the beginning of the program, the length of the tape must be specified. // The length is specified in feet. The normal play speed of the tape player // is 2.56 inches per second. // // There are six function buttons: play forward, play backward, faster, slower, // rewind, and stop. Each time a faster button is pressed, the tape speed is // doubled up to a preset maximum speed. Each time the slower button is pushed, // the tape speed is reduced by one half until a preset minimum speed is reached. // The rewind button moves the tape backward at the maximum speed. // // The display shows the current tape motion, speed, and position as well as // the percentage of tape used and the speed step and ratio to normal play speed. // // The program begins with initialization and input of the tape length. // // The program then prompts for and waits for commands. Four kinds of commands // are available: display the menu of commands, push a function button, advance // a specified number of seconds, and quit. Commands may be entered in either // upper case or lower case. Command words may be any length, but only the first // letter of a command is used. The A command advances the simulation by a // specified number of seconds. White space must separate the command letter // or word and the number of seconds. If no value is given or the value given // is invalid (not terminated by white space or the end of the line), an // increment of one is used. // // Each time a valid command is entered, it is executed, the tape player status // is displayed, and, if the command is not quit, the program then prompts for // and waits for the next command. // // When the quit command is executed, operation of the tape player is terminated, // final status is displayed, and program execution is terminated. // // Following is the menu of commands available in the program: // // Key Function // P Play forward // B Play backward // + Increase speed // - Decrease speed // R Rewind // S Stop tape // A Advance simulation // M Display menu // Q Quit simulation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
CS 31: Introduction to Computer Science I: Winter 2010: Project 6 Skeleton Page 2 //#define ECHO #include <iostream> #include <string> using namespace std; // ******************************************************************************** // * * // * GLOBAL CONSTANTS * // * * // ******************************************************************************** const int PLAY_SPEED = 2560; // Play speed: Milliinches per second const int MIN_SPEED = 80; // Minimum speed: Milliinches per second const int MAX_SPEED = 81920; // Maximum speed: Milliinches per second const int MIN_LENGTH = 100; // Minimum tape length: Feet const int MAX_LENGTH = 2400; // Maximum tape length: Feet const int MAX_STEPS = 10000; // Maximum advance steps const int STOP = 0; // Button number 0: Stop const int PF = 1; // Button number 1: Play forward
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern