Няма описание
Christian 60c1c9cd28 First source code commit преди 9 години
BPlayer.cpp First source code commit преди 9 години
BPlayer.h First source code commit преди 9 години
BPlayerClient.cpp First source code commit преди 9 години
README.md README.me преди 9 години
contributors.txt init преди 9 години
makefile First source code commit преди 9 години

README.md

Input Validation in Objects

Introduction

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.

Classes can use public and private member variables. In this lab you will learn the importance of creating private variables. You will implement the validating system in the class BPlayer.


The program that you will be editing is a Basketball Statistics Tracker. To understand the program you will need to learn basketball point system.

  • Free throw - counts 1 point
  • Field goal - counts 2 points
  • Three point - counts 3 points
  • Rebounds - add 1
  • Assist - add 1
  • Steals - add 1
  • Blocks - add 1
  • Fouls - add 1
  • Turnovers - add 1

Note that these variables are declared private, and they are unsigned short. Remember that unsigned short does not have negative numbers.

The program lets the user add or remove stats. You will need to implement a system in the setters that validates if the user wrongly removes stats. For example, if the player has 0 assist, and the user removes an assist, the setter will need to verify and tell the user.

Instructions

  1. In BPlayer.cpp, add input validation in:

    • void remPoints()
    • void remReb()
    • void remAst()
    • void remStl()
    • void remBlock()
    • void remFoul()
    • void remTurnover()
  2. Run and verify that it works.

  3. In BPlayerClient.cpp,

    • In the function void options(vector<BPlayer> &team, int &game), add input validation
    • Validate that the user never enters negative numbers
    • Validate that the user selects a team between 1 and 15.

References:

[1] http://cis1.towson.edu/~cssecinj/modules/cs0/input-validation-cs0-c/