Coin Class The coin class simulates a coin that can be tossed, resulting in heads or tails. You'll us the rand library to determine the coin is heads or tails when flipped (https://cplusplus.com/reference/cstdlib/rand/). Coin (denomination:string) The coin's constructor determines the coin's denomination (quarter, dime, nickel, penny You should stick to those 4 denominations (in lowercase) for now. We don't have any error checking, so you can't enforce this rule. The coin's denomination will determine its value. quarter is worth 25, dime is worth 10, nickel is worth 5, and a penny is worth 1. Public Interface: Coin(denomination:string) The coin constructor. o denomination should be limited to lower case quarter, dime, nickel or penny flip():void flips the coin making it heads up or tails up. isHeadsUp(): bool returns true if the coin is heads up and false if the coin is tails up. • value():int returns the value of the coin o quarter: 25, dime:10, nickel: 5 & penny: 1 Driver: The driver should demonstrate all the features of the class. Experimental Coin Tests When you're ready to run the automated test please also try the experimental coin test and let me know if it works I'm using the random seed to de-randomize the random coin test, but I don't know for 100% that it will work the same on all computers.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

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;
}

Coin Class
The coin class simulates a coin that can be tossed, resulting in heads or tails. You'll us the rand library to determine
the coin is heads or tails when flipped (https://cplusplus.com/reference/cstdlib/rand/).
Coin(denomination:string) The coin's constructor determines the coin's denomination (quarter, dime, nickel, penny)
You should stick to those 4 denominations (in lowercase) for now. We don't have any error checking, so you can't
enforce this rule. The coin's denomination will determine its value. quarter is worth 25, dime is worth 10, nickel is
worth 5, and a penny is worth 1.
Public Interface:
• Coin(denomination:string) The coin constructor.
o denomination should be limited to lower case quarter, dime, nickel or penny
flip():void flips the coin making it heads up or tails up.
• isHeadsUp():bool returns true if the coin is heads up and false if the coin is tails up.
• value():int returns the value of the coin
●
o quarter: 25, dime:10, nickel: 5 & penny: 1
Driver:
The driver should demonstrate all the features of the class.
Experimental Coin Tests
When you're ready to run the automated test please also try the experimental coin test and let me know if it works.
I'm using the random seed to de-randomize the random coin test, but I don't know for 100% that it will work the
same on all computers.
222, 222
Coin
+ Coincdenomination : string): void
+ get Denomination(): string
flip(): void
+ isHeads up(): bool
+ value() : int
+
Transcribed Image Text:Coin Class The coin class simulates a coin that can be tossed, resulting in heads or tails. You'll us the rand library to determine the coin is heads or tails when flipped (https://cplusplus.com/reference/cstdlib/rand/). Coin(denomination:string) The coin's constructor determines the coin's denomination (quarter, dime, nickel, penny) You should stick to those 4 denominations (in lowercase) for now. We don't have any error checking, so you can't enforce this rule. The coin's denomination will determine its value. quarter is worth 25, dime is worth 10, nickel is worth 5, and a penny is worth 1. Public Interface: • Coin(denomination:string) The coin constructor. o denomination should be limited to lower case quarter, dime, nickel or penny flip():void flips the coin making it heads up or tails up. • isHeadsUp():bool returns true if the coin is heads up and false if the coin is tails up. • value():int returns the value of the coin ● o quarter: 25, dime:10, nickel: 5 & penny: 1 Driver: The driver should demonstrate all the features of the class. Experimental Coin Tests When you're ready to run the automated test please also try the experimental coin test and let me know if it works. I'm using the random seed to de-randomize the random coin test, but I don't know for 100% that it will work the same on all computers. 222, 222 Coin + Coincdenomination : string): void + get Denomination(): string flip(): void + isHeads up(): bool + value() : int +
Expert Solution
steps

Step by step

Solved in 5 steps with 5 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education