Starting from:
$30

$24

Lab 0401 Solution




1. Problem Statement




Finish the given example of a custom/overridden <vector class.




2. Requirements




2.1 Assumptions




Uses the given header file definition and the start of main given.



Automatically tests and prints to screen



Console



2.2 Specifications




Will fill in given functions



Will test [set] [print] in main()



Decomposition Diagram



Program



Input



Technically N/A



Test Data is set Inline



Process



Perform Functions



print()



set()



Output



Print results to screen



Test Strategy



Valid Data



Invalid Data



5. Test Plan Version 1




Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Created / Not Initialized






















Valid Data
2
Created / Initialized






















Valid Data
3
Set Value 1, Position 0






















Valid Data
4
Set Value 2, Position 1






















Valid Data
5
Set Value 3, Position 2






















Valid Data
6
Set Vector C to D












(Deep Copy)






















Valid Data
7
Set Value 0, Position 1






















Valid Data
8
Redefined D, Print






















Valid Data
9
Deep Copy EMPTY






















Invalid Data
1
Set Value 0, Positiion -1






















Invalid Data
2
Set Value 4, Position 3






















Invalid Data
3
Set Size < 0































Initial Algorithm



Create Class Vector



Create Default Constructor



Set size = 0



Set entries to new int array/vector[size]



Create Size Constructor



If size < 0



ERROR



Else



Set size



Set entries to new int array/vector[size]



For (i = 0; i < size; i++) a. Fill entries with 0



Create Copy Constructor
Parameter: Constant Vector ​other
Set size = ​other​size



Set entries to new int array/vector[size]



For (i = 0; i < size; i++)



Fill entries with ​other​entries
Create Default Destructor



Create Function Print



Print First Bracket



Iterate and Print Each Index



Print Close Bracket



Create Function Set



If Position is out of bounds



ERROR



Else



Entry at Pos is Value



Create Main



Define Vectors a, b size 3, c size 3



Print a



Print b



Set c (0, -1)



Set c (1, 0)



Set c (2, 1)



Set c (3, 2)



Set c (4, 3)



Print c



Define Vector D as C



Print d



Set d (0, 1)



Print d



Print c



Test Plan Version 2






Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail














Valid Data
1
Created / Not Initialized
a.print()
[ ]


















Valid Data
2
Created / Initialized
b(3),
[000]










b.print()




















Valid Data
3
Set Value 1, Position 0
c.set(1,0)
1 @ 0


















Valid Data
4
Set Value 2, Position 1
c.set(2,1)
2 @ 1


















Valid Data
5
Set Value 3, Position 2
c.set(3,2)
3 @ 2


















Valid Data
6
Set Vector C to D
Vector d(c),
[123]








(Deep Copy)
d.print()




















Valid Data
7
Set Value 0, Position 1
d.set(0,1)
0 @ 1


















Valid Data
8
Redefined D, Print
d.print()
[103]


















Valid Data
9
Deep Copy EMPTY
e(a),
[ ]










e.print()




















Invalid Data
1
Set Value 0, Positiion -1
c.set(0,-1)
Error Message


















Invalid Data
2
Set Value 4, Position 3
c.set(4,3)
Error Message


















Invalid Data
3
Set Size < 0
f(-1)
Error Message




















More products