Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with writing the rest of the code in C++ and i am stuck if someone can please help. For this assignment you

I need help with writing the rest of the code in C++ and i am stuck if someone can please help.

For this assignment you will create a small program that reads a file containing different crypto currencies. The file you will need to read is Coins.csv. NOTE  

this is a text file.

--Coins.csv (the text file)

image text in transcribed

image text in transcribed

image text in transcribed

---CODE FOR THE CPP FILE. 
#include  #include  using namespace std; #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "doctest.h" const int COIN_COUNT = 50; /// An example class. class Cryptos { fstream fileObj; // use me to open the file and read the data. // Define Coin structure here. // Define coins array of Coin here. public: ////////// bool OpenFile(string fileName) { // Implement OpenFile here return true; // fixme: Return the actual success/fail of the file open } ////////// int ParseCurrencies() { // Implement ParseCurrencies here return COIN_COUNT; // fixme: Return the actual number of Coins read in to the array } ////////// int CountCoinsStartingWithLetter(const char ch) { // Implement CountCoinsStartingWithLetter here return 6; // fixme: Return the actual number of Symbols that start with the letter "ch" } }; /// Testing starts here. This takes the place of "main()" /// TEST_CASE("This is the unit tests for the Cryptos class") { Cryptos cryptos; CHECK(cryptos.OpenFile("TestData/Coins.csv") == true); CHECK(cryptos.ParseCurrencies() == COIN_COUNT); CHECK(cryptos.CountCoinsStartingWithLetter('a') != 5); CHECK(cryptos.CountCoinsStartingWithLetter('a') == 6); CHECK(cryptos.CountCoinsStartingWithLetter('a') != 7); }
- In the source file (CPP), create a class that contains: 3 public member functions: - A function named "OpenFile" to open the file and store the file object or data. The function should return true on success and false on failure. - A function named "ParseCurrencies" to read the data from the CSV file and place the data in an array of structures. The function should return an integer which is the count of structures in the internal array. - A function named "CountCoinsStartingWithLetter" to count the number of coins whose symbol begins with a particular letter (upper or lower case). The function should return the count of coins found. Member variables: - a structure definition containing the attributes of the crypto coin (use the Coins.csv file to determine this). - an array of crypto coin structures that gets filled with the data from the file. - A doctest Gtestcase that replaces "main()" and tests the results of each to the functions. As an example: TEST_CASE("Testing the crypto coins class") \{ Cryptos cryptos; CHECK(cryptos. OpenFile("coins.csv") == true); CHECK(cryptos. ParseCurrencies() == COIN_COUNT); CHECK(cryptos. CountCoinsStartingWithLetter('a') !=5); CHECK(cryptos. CountCoinsStartingWithLetter(' a))=6); CHECK(cryptos. CountCoinsStartingWithLetter(' a)!=7); \}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

Verify Eq. (21.28). (AB) = AB* + A*B 4 (21.28)

Answered: 1 week ago