elow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods. For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate Classes functionality. CoinTest.cpp #define CATCH_CONFIG_MAIN #include "../Coin.h" #include TEST_CASE("Should be able to create a coin") { Coin dime = Coin("dime"); } TEST_CASE("Should be able to get Coin Denomination") { Coin nickel = Coin("nickel"); REQUIRE("nickel" == nickel.getDenomination()); } TEST_CASE("Coin should be head up by default") { Coin penny = Coin("penny"); REQUIRE(penny.isHeadUp()); } TEST_CASE("Should be able to flip the coin") { Coin quarter = Coin("quarter"); quarter.flip(); } TEST_CASE("Should be able find out if the coin is Head Up") { Coin quarter = Coin("quarter"); quarter.flip(); bool heads = quarter.isHeadUp(); bool result = heads || !heads; REQUIRE(result); } CoinTestExperimental.cpp: #define CATCH_CONFIG_MAIN #include "../Coin.h" #include #include TEST_CASE("Coin should come up heads") { Coin lucky_penny = Coin("penny"); srand(1); lucky_penny.flip(); REQUIRE(lucky_penny.isHeadUp()); } TEST_CASE("Coin should come up tails") { Coin lucky_penny = Coin("penny"); srand(3); lucky_penny.flip(); REQUIRE(lucky_penny.isHeadUp()); }
B
elow for each class you find a UML and description of the public interface. Implementing the public interface as described is madatory. There's freedom on how to implement these classes.The private properties and private methods are under your control.. There are multiple ways of implementing all these classes. Feel free to add private properties and methods.
For each object, it's mandatory to create a header file (.h), implementation file (.cpp) and a driver. Blank files are included. The header should have the class definition in it. The implementation file should contain the implementations of the methods laid out in the header fine. And finally the Driver should test/demonstrate all the features of the class. It's best to develop the driver as the class is being written. Check each section to see if there are added additional requirements for the driver. Two test suites are included so that work can be checked. It's important to implement the drivers to test and demonstrate Classes functionality.
CoinTest.cpp
#define CATCH_CONFIG_MAIN
#include "../Coin.h"
#include <catch2/catch_test_macros.hpp>
TEST_CASE("Should be able to create a coin") {
Coin dime = Coin("dime");
}
TEST_CASE("Should be able to get Coin Denomination") {
Coin nickel = Coin("nickel");
REQUIRE("nickel" == nickel.getDenomination());
}
TEST_CASE("Coin should be head up by default") {
Coin penny = Coin("penny");
REQUIRE(penny.isHeadUp());
}
TEST_CASE("Should be able to flip the coin") {
Coin quarter = Coin("quarter");
quarter.flip();
}
TEST_CASE("Should be able find out if the coin is Head Up") {
Coin quarter = Coin("quarter");
quarter.flip();
bool heads = quarter.isHeadUp();
bool result = heads || !heads;
REQUIRE(result);
}
CoinTestExperimental.cpp:
#define CATCH_CONFIG_MAIN
#include "../Coin.h"
#include <catch2/catch_test_macros.hpp>
#include <stdlib.h>
TEST_CASE("Coin should come up heads") {
Coin lucky_penny = Coin("penny");
srand(1);
lucky_penny.flip();
REQUIRE(lucky_penny.isHeadUp());
}
TEST_CASE("Coin should come up tails") {
Coin lucky_penny = Coin("penny");
srand(3);
lucky_penny.flip();
REQUIRE(lucky_penny.isHeadUp());
}
Coin.h:
#include <string>
#include <stdlib.h> // for rand()
#ifndef COIN_H
#define COIN_H
#endif //COIN_H
Coin.cpp :
#include "Coin.h"
CoinDriver.cpp:
#include <iostream>
#include "Coin.h"
int main() {
std::cout << "Hello, CoinDriver!" << std::endl;
return 0;
}
CoinGame.cpp:
#include <iostream>
#include "Coin.h"
int main() {
std::cout << "Hello, Coin Game!" << std::endl;
return 0;
}


Step by step
Solved in 3 steps









