|
@@ -1,6 +1,6 @@
|
1
|
1
|
#Input Validation in Objects
|
2
|
2
|
|
3
|
|
-## Introduction
|
|
3
|
+##Introduction
|
4
|
4
|
|
5
|
5
|
It is important to check all input. A program input can be used to delete or damage data, obtain sensitive information or propogate worms. All input must be threated as potentially dangerous.
|
6
|
6
|
|
|
@@ -10,15 +10,15 @@ Classes can use public and private member variables. In this lab you will learn
|
10
|
10
|
|
11
|
11
|
The program that you will be editing is a Basketball Statistics Tracker.
|
12
|
12
|
To understand the program you will need to learn basketball point system.
|
13
|
|
-* Free throw - counts 1 point
|
14
|
|
-* Field goal - counts 2 points
|
15
|
|
-* Three point - counts 3 points
|
16
|
|
-* Rebounds - add 1
|
17
|
|
-* Assist - add 1
|
18
|
|
-* Steals - add 1
|
19
|
|
-* Blocks - add 1
|
20
|
|
-* Fouls - add 1
|
21
|
|
-* Turnovers - add 1
|
|
13
|
+*Free throw - counts 1 point
|
|
14
|
+*Field goal - counts 2 points
|
|
15
|
+*Three point - counts 3 points
|
|
16
|
+*Rebounds - add 1
|
|
17
|
+*Assist - add 1
|
|
18
|
+*Steals - add 1
|
|
19
|
+*Blocks - add 1
|
|
20
|
+*Fouls - add 1
|
|
21
|
+*Turnovers - add 1
|
22
|
22
|
|
23
|
23
|
Note that these variables are declared private, and they are unsigned short.
|
24
|
24
|
Remember that unsigned short does not have negative numbers.
|
|
@@ -27,15 +27,21 @@ The program lets the user add or remove stats. You will need to implement a syst
|
27
|
27
|
|
28
|
28
|
**Instructions**
|
29
|
29
|
1. In `BPlayer.cpp`, add input validation in:
|
30
|
|
- * `void remPoints();`
|
31
|
|
- * `void remReb();`
|
32
|
|
- * `void remAst();`
|
33
|
|
- * `void remStl();`
|
34
|
|
- * `void remBlock();`
|
35
|
|
- * `void remFoul();`
|
36
|
|
- * `void remTurnover();`
|
|
30
|
+ *`void remPoints();`
|
|
31
|
+ *`void remReb();`
|
|
32
|
+ *`void remAst();`
|
|
33
|
+ *`void remStl();`
|
|
34
|
+ *`void remBlock();`
|
|
35
|
+ *`void remFoul();`
|
|
36
|
+ *`void remTurnover();`
|
37
|
37
|
2. Run and verify that it works.
|
38
|
38
|
3. In `BPlayerClient.cpp`,
|
39
|
|
- * In the function `void options(vector<BPlayer> &team, int &game)`, add input validation
|
40
|
|
- * Validate that the user never enters negative numbers
|
41
|
|
- * Validate that the user selects a team between 1 and 15.
|
|
39
|
+ *In the function `void options(vector<BPlayer> &team, int &game)`, add input validation
|
|
40
|
+ *Validate that the user never enters negative numbers
|
|
41
|
+ *Validate that the user selects a team between 1 and 15.
|
|
42
|
+
|
|
43
|
+---
|
|
44
|
+
|
|
45
|
+##References:
|
|
46
|
+
|
|
47
|
+ [1] http://cis1.towson.edu/~cssecinj/modules/cs0/input-validation-cs0-c/
|