Numerical List Documentation
-
Upload
vitalie-mihailov -
Category
Documents
-
view
215 -
download
0
Transcript of Numerical List Documentation
-
7/30/2019 Numerical List Documentation
1/4
Date: 16.10.2012 Name: Candale Andrei
Problem Statement:A math teacher needs a program in order to help students to test different properties of
numbers. The program manages a list of numbers and also allows students to repeatedly
execute various functionalities.
Numerical Lists Feature List
F1. Add a number to the list.
F2. Insert a numberat a given position.
F3. Remove a numberfrom a given position.
F4. Remove all numbers between two given positions.
F5. Replace all occurences ofa sublist with another sublist.
F6. Write all prime numbers between two given positions.
F7. Write all odd numbers between two given position.
F8. Compute the sum of all numbers between two given positions.
F9. Compute the greatest common divisior of all numbers between two given positions.
F10. Compute the maximum of all numbers between two given positions.
F11. Filter only the prime numbers.
F12. Filter only the negative numbers.
F13. Undo last performed operation.
Iteration Plan:Iteration Planned Features
I1.
F1. Add a number to the list.
F2. Insert a numberat a given position.
F3. Remove a numberfrom a given position.
F4. Remove all numbers between two given positions.
F5. Replace all occurences ofa sublist with another sublist.
I2.
F6. Write all prime numbers between two given positions.
F7. Write all odd numbers between two given position.F8. Compute the sum of all numbers between two given positions.
F9. Compute the greatest common divisior of all numbers between two given positions.
F10. Compute the maximum of all numbers between two given positions.
F11. Filter only the prime numbers.
F12. Filter only the negative numbers.
F13. Undo last performed operation.
I3.
-
7/30/2019 Numerical List Documentation
2/4
Iteration 1
Work items:
Running Scenario Add feature (F1)
Add feature (F1)
User Program DescriptionPlease type your command or'help' to see a full list ofcommands.
Menu
help Ask for all the available commandsadd value - adds a value to the end
of the list
...
Returns all the available commands
add 1 Add number to the end of the list
[1] Returns the list
add a Add a character
The second parameter must be a
number
The program alerts the user that the
values are not correct.
ad 2 The user executes an incorrect
commandThe command you entered is notvalidPlease type your command or'help' to see a full list ofcommands.
The program alerts theuser that the
command was incorrect
Insert a numberat a given position (F2)
insert -1 at 0 Insert -1 at position 0
[-1,1] Returns the list
insert -2 at -10 Tries to insert -2 atthe position -10
[-2,-1,1] The program inserts the number at
the first position
insert 2 at 100 Insert 2 at position 100[-2,-1,1,2] The program inserts the number at
T1. Implement a procedure to decode the users input for each feature
from F1 to F13T2. Implement a procedure to execute the users command for each
feature from F1 to F13.
T3. Implement auxiliary functions:
- prime number check (for F6)
- gratest common divizior (for F9)
T4. Implement user interface.
-
7/30/2019 Numerical List Documentation
3/4
the last position
Remove a numberfrom a given position(F3)
remove 1 Remove the value from position 1
[-1,1,2] Returns the list
remove -1 Return the value at position -1
The position must be a naturalnumber between 0 and the lengthof the list.
The program alerts the user thatsuch an operation is not posible
Remove all numbers between two given positions (F4)
remove from 0 to
2
Remove all the values in between
the positions 0 and 2
[2] Returns the list
Replace all occurences ofa sublist with another sublist (F5)
replace 2 with 1 2
3 4
Replace all the occurrences of 2
with the list 1 2 3 4
[1,2,3,4]
replace 1 2 with-1 -2 -3
Replace all the occurrences of thesublist 1 2 with the sublist -1 -2 -3
[-1, -2, -3, 3, 4] Returns the list
Write all prime numbers between two given positions. (F6)
prime from 0 to 2 Returns the prime numbers in
between position 0 and 2
[-2,-3] Returns the list
prime from 3 to 0 Return prime numbers in between
position 3 and 0The first position cannot begreater than the last one
The program alerts the user
thatsuch an operation cannont bedone
Write all odd numbers between two given position (F7)
odd from 0 to 4 Return the odd number in between
the position 0 and 5[-1, -3, 3] Returns the list
Compute the sum of all numbers between two given positions. (F8)
sum from 0 to 3 Returns the sum of the elements in
between the positions 0 and 3
-3 Returns the sum
Compute the greatest common divisior of all numbers between two given positions (F9)
gcd from 0 to 4 Returns the greatest commondivizor in between positions 0 and
4
1 Returns result
. Compute the maximum of all numbers between two given positions (F10)
max from 0 to 3 Returns the maximum value in
between position 0 and 3
3 Returns the result
Filter only the prime numbers (F11)
filter prime Returns the prime numbers from
the list[-2, -3, 3] Returns the sublist with prime
-
7/30/2019 Numerical List Documentation
4/4
numbers
Filter only the negative numbers (F12)
filter negative Returns the negative numbers from
the list[-1, -2, -3] Returns thesublist with negative
numbersUndo last performed operation (F13)
undo Reverses the last operation
[1,2,3,4]