Programming Assignment 1 and 2
- Vpqnrqhwk
- Rating : 40
- Grade : A+
- Questions : 2
- Solutions : 1079
- Blog : 0
- Earned : $19352.58
Software Design Document for Secret Simulation
Programming Assignment 1 and Programming Assignment 2 complete solution correct answer key
Prepared For
Dr. Rick Coleman, Instructor
CS 221, Data Structures in C++
Computer Science Department
University of Alabama in Huntsville
Software Design Document
Secret Simultation
1.0 System Overview
A secret government agency has need of a special Abstract Data Type (ADT) for use in a Basically Secret Simulation (BSS). The ADT may be thought of abstractly as three queues (3Qs). The 3Qs each can hold the same type of data structure. Commands at regular time intervals (CARTI) will be sent to this portion of the BSS. Command one (C1) will be to dynamically create a data structure (DCDS), place into the data structure information to be supplied (TBS), and enqueue it into the first queue (Queue A). Command two and three (C2 and C3) will be to dequeue a structure from Queue A and immediately enqueue it into Queue B (C2) or Queue C (C3). Command four and five (C4 and C5) will be to dequeue and destroy a structure from either Queue B (C4) or Queue C (C5). Details of this functionality are given in section 2.0. As usual should you or any of your programming team divulge even the smallest bit of information about this BSS we will have to shoot you.
2.0 Referenced Documents
- Programming Assignment 1 Statement of Work.
- Dale, Nell and Teague, David, C++ Plus Data Structures 2nd ed. 2001.
- “Programming Assignment 2 Hints” web page, http://cs.uah.edu/~rcoleman/CS221/ProgAssign/cs221Prog2Hints.html
3.0 Architectural Design
3.1 Concept of Execution
This program will be a simple command line application with a text only interface. When started the application will display the title and copyright information on the application and instructions on its use. When the user presses any key the screen will be cleared then the application will enter its main execution loop.
In the main execution loop the main menu will be displayed (see Appendix A for diagram of the main menu). The user will be asked to enter a number corresponding to his/her choice of actions from the main menu. That action will then be executed. This will continue until the user selects the Quit option at which time the application will exit the main execution loop and terminate.
3.2 Abstract Data Type
The task list will be implemented as a linked list with all list functions and data stored in a single C++ class to be called ToDoList.
3.3 Code Outline
This program will consist of the following files:
Prog1Class.cpp - This file will instantiate an instance of the ToDoList class, implement the user interface, and handle all interactions between the user and the ToDoList object.
Class: Prog1Class.h and Program1Class.cpp
1. Void setIntVal(int val) – Stores a single argument value in the member variable m_iVal
2. Void setDoubleVal(double val) – Stores a single argument value in the member variable m_dval
3. Void setStringVal(char*val) – Stores a char array string single argument in the member variable m_sLine
4. Void setStructVals(in arg1, double arg2, char*arg3) --
4.0 Detailed Design
4.1 Source File: ProgXMain.cpp
4.1.1 Function: main()
4.1.1.1 Purpose
This function will control the display of all screens and the user interface.
4.1.1.2 Arguments
int argc -- standard argument to main() giving the number of command line arguments. Not used.
char **argv -- standard argument to main(). Pointer to an array of pointes to char listing the command line arguments. Not used.
4.1.1.3 Return value
The function returns an int. Using standard programming procedure the value of zero will be returned to indicate to the operating system normal termination of the program without error.
4.1.1.4 Function outline in pseudocode
Instantiate a ToDoList object and other variables as needed
Print program title and instructions
Print prompt to user requesting "Press any key to continue."
Input key press
Clear screen
Begin Loop
Display main menu
Get user input
if (valid input)
switch on input number
1 = Call clearList()
2 = Get task info from user then call insert()
3 = Get task info from user then call delete()
4 = Get task info from user then call getNestTask
and print the info on this task()
5 = Call printList()
6 = Exit loop and terminate application
End Loop
Print farwell message
4.1.1.5 Tracability
This function will partially fulfill requirements 2.1 through 2.5 of the SOW by providing a user interface through which the user can execute all the functions of the application.
4.2 Source File: ToDoList.h and ToDoList.cpp
4.2.1 Function: ClearList()
4.2.1.1 Purpose
This function will remove all nodes from the task list and free all memory associated with a list so a new list can be built
4.2.1.2 Arguments
None. Function accesses the list via the pointer member variable.
4.2.1.3 Return value
The function returns void.
4.2.1.4 Function outline in pseudocode
Declare temp pointer to item structure
Set temp pointer to head of list
While temp is not null
Set head pointer to head->next
Delete node temp points to
Advance temp to head
End While
4.2.1.5 Tracability
This function partially fulfills requirement 2.1 of the SOW by clearing any old list before the user creates a new list.
4.2.2 Function: Insert()
4.2.2.1 Purpose
This function adds a task to the list. Tasks are inserted into the list in order with those tasks with lower priorities placed toward the front of the list.
4.2.2.2 Arguments
char *task Pointer to a character string holding the task.
int priority Integer defining the priority of the task.
4.2.2.3 Return value
The function returns void.
4.2.3.4 Function outline in pseudocode
Declare temp and back pointer to ToDoItem structures
if head == null return - nothing to delete
Set back = null and temp = head
While temp != null and temp priority != key priority
Advance back to temp and temp to temp->next
End While
If back == null delete first node in list
Set head = temp->next
Delete node pointed to by temp
Else if temp != null delete from middle or end of list
Set back next = temp next
Delete node pointed to by temp
Else (temp is null) so report node not found
4.2.3.5 Tracability
This function partially fulfills requirement 2.2 of the SOW by removing items to the list.
4.2.4 Function: GetNextTask()
4.2.4.1 Purpose
This function gets the next task in the list.
4.2.4.2 Arguments
None. Function accesses the list via the pointer member variable.
4.2.4.3 Return value
Pointer to dynamically allocated character string that is a duplicate of the task string stored in the first node of the list.
4.2.4.4 Function outline in pseudocode
Declare pointer to character
if head == null return null as list is empty
Else
Create new char array and set pointer to it
Copy task string from first node into new array
Call Delete function to remove node at head of list.
Return pointer to task string.
4.2.4.5 Tracability
This function partially fulfills requirement 2.4 of the SOW by fetching the next task in the list.
4.2.5 Function: PrintList()
4.2.5.1 Purpose
This function prints all tasks in the list on the screen.
4.2.5.2 Arguments
None. Function accesses the list via the pointer member variable.
4.2.5.3 Return value
This function returns void
4.2.5.4 Function outline in pseudocode
Declare temp pointer to ToDoItem structure
Set temp pointer to head of list
While temp pointer is not null
Print task and priority of node pointed to by temp
Advance temp to temp next
4.2.5.5 Tracability
This function partially fulfills requirement 2.5 of the SOW by fetching the next task in the list.
Appendix A
Sample Main Screen Display
____________________________________________________________________
H O N E Y D E W L I S T
Things I gotta do today.
____________________________________________________________________
What would you like to do?
1. Start a new task list.
2. Add a task to the current list.
3. Remove a task from the current list.
4. Get the next task in the list.
5. Quit.
Enter the number of your choice then press [Enter]...
___________________________________________________________________
[Solved] Programming Assignment 1 and 2
- This solution is not purchased yet.
- Submitted On 21 Jul, 2015 07:46:00
- Vpqnrqhwk
- Rating : 40
- Grade : A+
- Questions : 2
- Solutions : 1079
- Blog : 0
- Earned : $19352.58