Vous êtes sur la page 1sur 21

While designing the engineering tools inventory control system program three stages

of pseudocode were created:

First stage pseudocode:


DO Tools inventory control system
Welcome (FUNCTION):
Display_menu_options (FUNCTION):
Option = get_menu_selection (FUNCTION):

CASE Option
1 = Load file
2 = Display contents of data base
3 = Insert new tool record
4 = Delete tool record
5 = Update existing tool record
6 = Search for tool stock by name
7 = Save file
8 = Exit program

WHILE (option < 1 or option > 8)


LOOP
Write out ‘End of program’
END LOOP

Welcome (FUNCTION):
Write out ‘WELCOME TO TOOLS INVENTORY CONTROL
SYSTEM’

Display_menu_options (FUNCTION):
Write out ‘An Engineer's Tools Inventory Control Options’
1) Load database
2) Display all records
3) Insert new tool record
4) Delete tool record
5) Update existing tool record
6) Search for tool stock by name
7) Save database
8) Exit from program
Write out ‘Please select option 1-8:’

Get_menu_selection (FUNCTION):
Read in option
WHILE (option < 1 or option > 8)
LOOP
Write out ‘Invalid input – Please try again’
Read in option
END LOOP
END DO Tools inventory control system
Second stage pseudocode:
DO Tools inventory control system
Set max_entries to 20
Welcome (FUNCTION):
Display_menu_options (FUNCTION):
Option = get_menu_selection (FUNCTION):

CASE Option
1 = Load_file(FUNCTION)
2 = display_buffer_contents(FUNCTION)
3 = insert_buffer_contents(FUNCTION)
4 = delete_buffer_contents(FUNCTION)
5 = update_buffer_contents(FUNCTION)
6 = search_buffer_contents(FUNCTION)
7 = save_database_file(FUNCTION)
8 = Exit program

WHILE (option < 1 or option > 8)


LOOP
Write out ‘End of program’
END LOOP

Welcome (FUNCTION):
Write out ‘WELCOME TO TOOLS INVENTORY CONTROL
SYSTEM’

Display_menu_options (FUNCTION):
Write out ‘An Engineer's Tools Inventory Control Options’
1) Load database
2) Display all records
3) Insert new tool record
4) Delete tool record
5) Update existing tool record
6) Search for tool stock by name
7) Save database
8) Exit from program
Write out ‘Please select option 1-8:’

Get_menu_selection (FUNCTION):
Read in option
WHILE (option < 1 or option > 8)
LOOP
Write out ‘Invalid input – Please try again’
Read in option
END LOOP
Display_buffer_contents (FUNCTION)
Write out ‘Tool Name Date of Stock Quantity Cost’
FOR (int i =0; i<max_entries; i++)
LOOP
Write out ‘buffer[i].recordno’ buffer[i].name<<"\t\t"<<
buffer[i].stock_date.day<<"/"
<<buffer[i].stock_date.month<<"/"<<buffer[i].stock_date.year
<<"\t"<< buffer[i].quantity<<"\t\t"<< buffer[i].cost
END LOOP

Insert_buffer_contents(FUNCTION)
Write out ‘please enter record number’
Read in ‘choice’
WHILE (choice < 1 or choice > 20)
LOOP
Write out ‘Input file contains errors!’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’;
END LOOP

buffer[choice-1].recordno = choice;
cout<<"\n\tTool name:";
cin>>buffer[choice-1].name;
cout<<"\n\tQuantity: ";
cin>>buffer[choice-1].quantity;
cout<<"\n\tPrice: ";
cin>>buffer[choice-1].cost;
cout<<"\n\t(Date)";
cout<<"\n\tDay: ";
cin>>buffer[choice-1].stock_date.day;
cout<<"\n\tMonth: ";
cin>>buffer[choice-1].stock_date.month;
cout<<"\n\tYear: ";
cin>>buffer[choice-1].stock_date.year;

delete_buffer_contents(FUNCTION)
Write out ‘Please enter record to delete:’
Read in choice;
WHILE (choice < 1 or choice > 20)
LOOP
Write out ‘Invalid update request!’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’;
END LOOP

Write out ‘Are you sure (y/n)?’


Read in option
WHILE (option != 'y' and option != 'n')
LOOP
Write out ‘Invalid input! please enter y or n:!’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’;
END LOOP

IF (option == 'y' )
LOOP

buffer[choice-1].recordno = 0;
buffer[choice-1].quantity = 0;
buffer[choice-1].cost = 0.0;
strcpy(buffer[choice-1].name,"None");
buffer[choice-1].stock_date.day = 0;
buffer[choice-1].stock_date.month = 0;
buffer[choice-1].stock_date.year = 0;

Write out ‘Record has been deleted’


END LOOP

ELSE IF (option == 'n')


LOOP
Write out ‘Record has not been deleted’
END LOOP

update_buffer_contents(FUNCTION)
Write out ‘please enter record number (1-20)’
Read in choice;
WHILE (choice < 1 or choice > 20)
LOOP
Write out ‘Invalid update request!’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’;
END LOOP
Write out ‘New quantity:’
Read in buffer[choice-1].quantity;
Write out ‘New Price:’
Read in buffer[choice-1].cost;
Write out ‘Day:’
Read in buffer[choice-1].stock_date.day;
Write out ‘Month:’
Read in buffer[choice-1].stock_date.month;
Write out ‘Year:’
Read in buffer[choice-1].stock_date.year;

search_buffer_contents(FUNCTION)
Write out ‘Please enter the name of the tool:’
Read in tool_name
FOR (int i =0; i<max_entries; i++)
LOOP
IF ((strcmp (tool_name, buffer[i].name)==0)
LOOP
cout<<"\n\t"<<buffer[i].name<<"found in record
"<<buffer[i].recordno
<<"\n\t"<<"Quantity: "<< buffer[i].quantity
<<"\n\t"<<"Price: "<<buffer[i].cost<<"\n";
END LOOP
END LOOP

IF ((strcmp (tool_name, buffer[i].name)!=0)


LOOP
Write out ‘Tool name not found!’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’
END LOOP

save_database_file(FUNCTION)
Write out ‘Please enter file name’
Read in filename
OPEN filename
FOR (counter = 0; counter <= 20; counter++)
LOOP
fp<<buffer[counter].name<<buffer[counter].recordno<<
buffer[counter].quantity<<buffer[counter].cost;
END LOOP
CLOSE filename
Write out ‘filename saved !’
Write out ‘press A CHARACTER and then ENTER to continue
Read in ‘character’
END DO Tools inventory control system
Test number Date Purpose of Expected Actual result
test result
1 24-03-2009 Insert new tool Must prompt Unsuccessful.
record the user to Refer to fig 1
inset new tool
details
3 25-03-2009 Check the If the record Successful
record number number is out Refer to fig 3.
(1-20) for of range the
menu option 3 program must
(insert new display an
tool record) error message.
4 25-03-2009 Check error If the entered Successful
before deleting record number Refer to fig 4.
record is not between
1 and 20 then
the program
must show
error message
and return to
main menu
5 25-03-2009 Ask question Must display Successful
before deleting an error Refer to fig 5.
a record (y for message if the
yes and n for user inputs
no). value other
than y or n.
6 31-03-2009 Delete new If the user Successful
tool record wants to delete Refer to fig 6.
any tool record
then it must
delete the tool
record
7 31-03-2009 Update Must update Unsuccessful
existing tool the existing Refer to fig 7.
record tool record
features such
as quantity,
price, date
8 31-03-2009 Check error for If the entered Successful
update record record number Refer to fig 8.
option is not between
1 and 20 then
the program
must show
error message
and return to
main menu.
9 31-03-2009 Update Must update Successful
existing tool the existing Refer to fig 9.
record tool record
features such
as quantity,
price, date
10 31-03-2009 Check record Must display Unsuccessful
error for menu an error Refer to fig 10.
option 6 i.e. message if the
search tool tool name is
invalid.
11 28-04-2009 Search tool Must search Unsuccessful
Figure 1
Figure 2
Figure 3
Figure 4

Figure 5
Figure 6
Figure 7

Figure 8
Figure 9
Figure 10
Figure 11
Figure 12
Figure 13
Figure 14
Figure 15
Figure 16