$24
Vehicle Individual
Algorithm
Create Class Vehicle
Create Private Variables
Integer age
Float price
Create Function
Name: setAge
Parameters: integer input
Return: void
Create Function
Name: setPrice
Parameters: float input
Return: void
Create Function
Name: getAge
Parameters: n/a
Return: integer age
Create Function
Name: getPrice
Parameters: n/a
Return: float price
Create Main Function
Show default constructor
Attempt setting age to 18
Attempt setting price to $8,325.04
Attempt setting age to -1
Attempt setting price to -1
Test Plan
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Default Constructor
Default
Age = 0
Age = 0
Pass
Price = 0.0
Price = 0.0
Valid Data
2
Set Age
18
Age = 18
Age = 18
Pass
Valid Data
3
Get Age
^^
Age = 18
Age = 18
Pass
Valid Data
4
Set Price
8325.04
Price = 8325.04
Price = 8325.04
Pass
Valid Data
5
Get Price
^^
Price = 8325.04
Price = 8325,04
Pass
Invalid Data
1
Set Age
-1
Invalid Age
Invalid Age
Pass
Invalid Data
2
Set Price
-1
Invalid Price
Invalid Price
Pass
Snippets
Code
[vehicleIndividual.cpp]
//Vehice Individual Definition and Test
#include <iostream
#include "vehicle.h"
int main()
{
vehicle example;
//Testing Defaults
std::cout << example.getAge() << std::endl;
std::cout << example.getPrice() << std::endl;
//Testing Valid
example.setAge(18);
std::cout << example.getAge() << std::endl;
example.setPrice(8325.04);
std::cout << example.getPrice() << std::endl;
//Testing Invalid
example.setAge(-1);
example.setPrice(-1);
system("pause");
return 0;
}
[vehicle.h]
#pragma once
#include <iostream
#ifndef VEHICLE_H
#define VEHICLE_H
class vehicle
{
public:
vehicle(); //Default Constructor Primitive
void setAge(int);
void setPrice(float);
int getAge();
float getPrice();
~vehicle();
//Default Constrcutor Primitive
private:
int age;
//Age of the vehicle
float price; //Price of the vehicle
};
#endif VEHICLE_H
[vehicle.cpp]
#include "vehicle.h"
//Default Constructor
vehicle::vehicle()
{
age = 0;
price = 0.0;
}
//Setter Commands
void vehicle::setAge(int input)
{
if (input = 0)
{
age = input;
}
else
{
std::cout << "Invalid Age" << std::endl;
}
}
void vehicle::setPrice(float input)
{
if (input = 0)
{
price = input;
}
else
{
std::cout << "Invalid Price" << std::endl;
}
}
//Getter Commands
int vehicle::getAge()
{
return age;
}
float vehicle::getPrice()
{
return price;
}
//Default Destructor
vehicle::~vehicle()
{
}
Car Individual
Algorithm
Create Class Car
a. Create Private Variables
Bool Race Car Status
Create Function
Name: setRaceCarStatus
Parameters: bool input
Return: void
Create Function
Name: getRaceCarStatus
Parameters: n/a
Return: bool
Create Main Function
Show Default Constructor
Attempt setting RaceCarStatus to true
Test Plan
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Default Constructor
Default
0
0
Pass
Valid Data
2
Set Race Car
true
1
1
Pass
Snippets
Code
[carIndividual.cpp]
//Car Individual Definition and Test
#include <iostream
#include "car.h"
int main()
{
car mustang;
//Testing Valid
std::cout << mustang.getRaceCarStatus() << std::endl; mustang.setRaceCarStatus(true);
std::cout << mustang.getRaceCarStatus() << std::endl;
system("pause");
return 0;
}
[car.h]
#pragma once
#include <iostream
#include "vehicle.h"
#ifndef CAR_H
#define CAR_H
class car: public vehicle
{
public:
car(); //Default Constructor
void setRaceCarStatus(bool);
bool getRaceCarStatus();
~car(); private:
//Default Destructor
bool RaceCarStatus;
};
#endif CAR_H
[car.cpp]
#include "car.h"
//Default Constructor
car::car()
{
RaceCarStatus = 0;
}
//Setter
void car::setRaceCarStatus(bool input)
{
RaceCarStatus = input;
}
//Getter
bool car::getRaceCarStatus()
{
return RaceCarStatus;
}
//Default Destructor
car::~car()
{
}
Vehicle and Car Combined
Algorithm
Create Class Vehicle
Create Private Variables
Integer age
Float price
Create Function
Name: setAge
Parameters: integer input
Return: void
Create Function
Name: setPrice
Parameters: float input
Return: void
Create Function
Name: getAge
Parameters: n/a
Return: integer age
Create Function
Name: getPrice
Parameters: n/a
Return: float price
Create Class Car
Create Private Variables
Bool Race Car Status
Create Function
Name: setRaceCarStatus
Parameters: bool input
Return: void
Create Function
Name: getRaceCarStatus
Parameters: n/a
Return: bool
Create Main Function
Show default constructor
Attempt setting age to 31
Attempt setting price to $12,345.67
Attempt setting RaceCarStatus to true
Attempt setting age to -1
Attempt setting price to -1
Test Plan
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Default Constructor
Default
Age = 0
Age = 0
Pass
Price = 0.0
Price = 0.0
Race Car = 0
Race Car = 0
Valid Data
2
Set Age
18
Age = 18
Age = 18
Pass
Valid Data
3
Get Age
^^
Age = 18
Age = 18
Pass
Valid Data
4
Set Price
12,345.67
Price = 12,345.67
Price = 12,345.67
Pass
Valid Data
5
Get Price
^^
Price = 12,345.67
Price = 12,345.67
Pass
Valid Data
6
Set Race Car
true
1
1
Pass
Invalid Data
1
Set Age
-1
Invalid Age
Invalid Age
Pass
Invalid Data
2
Set Price
-1
Invalid Price
Invalid Price
Pass
Truck Individual
Algorithm
Create Class Truck
Create Private Variables
Bool Diesel Type Status
Create Function
Name: setDieselTypeStatus
Parameters: bool input
Return: void
Create Function
Name: getDieselTypeStatus
Parameters: n/a
Return: bool
Create Main Function
Show Default Constructor
Attempt setting DieselTypeStatus to true
Test Plan
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Default Constructor
Default
0
0
Pass
Valid Data
2
Set Diesel Type
true
1
1
Pass
Vehicle, Car, and Truck Combined
Algorithm
Create Class Vehicle
Create Private Variables
Integer age
Float price
Create Function
Name: setAge
Parameters: integer input
Return: void
Create Function
Name: setPrice
Parameters: float input
Return: void
Create Function
Name: getAge
Parameters: n/a
Return: integer age
Create Function
Name: getPrice
Parameters: n/a
Return: float price
Create Class Car
Create Private Variables
Bool Race Car Status
Create Function
Name: setRaceCarStatus
Parameters: bool input
Return: void
Create Function
Name: getRaceCarStatus
Parameters: n/a
Return: bool
Create Class Truck
Create Private Variables
Bool Diesel Type Status
Create Function
Name: setDieselTypeStatus
Parameters: bool input
Return: void
Create Function
Name: getDieselTypeStatus
Parameters: n/a
Return: bool
Create Main Function
Testing Car
Show Default Constructor for car
Attempt setting age to 31
Attempt setting price to $12,345.67
Attempt setting RaceCarStatus to true
Attempt setting age to -1
Attempt setting price to -1
Testing Truck
Show Default Constructor for truck
Attempt setting age to 18
Attempt setting price to $8,325.04
Attempt setting DieselTypeStatus to true
Attempt setting age to -1
Attempt setting price to -1
Test Plan
Test Strategy
#
Description
Input
Expected Output
Actual Output
Pass/Fail
Valid Data
1
Default Constructor
Default
Age = 0
Age = 0
Pass
of car
Price = 0.0
Price = 0.0
Race Car = 0
Race Car = 0
Valid Data
2
Set Age
31
Age = 31
Age = 31
Pass
Valid Data
3
Get Age
^^
Age = 31
Age = 31
Pass
Valid Data
4
Set Price
12,345.67
Price = 12,345.67
Price = 12,345.67
Pass
Valid Data
5
Get Price
^^
Price = 12,345.67
Price = 12,345.67
Pass
Valid Data
6
Set Race Car
true
1
1
Pass
Valid Data
7
Default Constructor
Default
Age = 0
Age = 0
of truck
Price = 0.0
Price = 0.0
Diesel Type = 0
Diesel Type = 0
Valid Data
8
Set Age
18
Age = 18
Age = 18
Valid Data
9
Get Age
^^
Age = 18
Age = 18
Valid Data
10
Set Price
8,325.04
Price = 8325.04
Price = 8325.04
Valid Data
11
Get Price
^^
Price = 8325.04
Price = 8325.04
Valid Data
12
Set Diesel
true
1
1
Invalid Data
1
Set Car Age
-1
Invalid Age
Invalid Age
Pass
Invalid Data
2
Set Car Price
-1
Invalid Price
Invalid Price
Pass
Invalid Data
3
Set Truck Age
-2
Invalid Age
Invalid Age
Pass
Invalid Data
4
Set Truck Price
-2
Invalid Price
Invalid Price
Pass