Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code for a project. However I keep getting several errors which I have pasted at the end of the code. If I

This is my code for a project. However I keep getting several errors which I have pasted at the end of the code. If I could get some help figuring out what I need to change, it would be much appreciated.

//Add libraries, namespace, structure and functions #include #include #include #include #include using namespace std; //functions void printMenu(); void addKitten(struct kitten& k, struct roster& r); bool deleteKitten(string name, struct roster* r); int findKitten(string str, struct roster* r); void getKittenFromFile(string str, struct roster& r); bool updateKitten(struct kitten* k, struct roster* r); void printToFile(string str, struct roster* r); void printRoster(struct roster* r); //kitten structure struct kitten { string name; string color; int score; }; //roster structure struct roster { int size = 0; kitten kittens[10]; }; int main() { struct roster kittenRoster; kittenRoster.size = 0; struct kitten k; string n; string c; string name; int x; char menuChoice; bool bool1; string fileName; //menu function do { printMenu(); cin >> menuChoice; switch(menuChoice) { case 'a': //adding kitten cout > k.score; addKitten(k, kittenRoster); break; case 'd': //deleting kitten cout > k.name; bool1 = deleteKitten(k.name, &kittenRoster); if (bool1 == false) cout > k.name; cout > k.color; cout > k.score; bool1 = updateKitten(&k, &kittenRoster); if (bool1) cout > fileName; getKittenFromFile(fileName, kittenRoster); break; case 's': //printing from file cout > name; printToFile(name, &kittenRoster); break; case 'o': //printing whole roster printRoster(&kittenRoster); cout size; i++) { if (r->kittens[i].name == str){ return i; } } return -1; } //function for adding kitten void addKitten(struct kitten& k, struct roster& r) { if (r.size >= 10) { cout size-1) { r -> kittens[x] = r->kittens[x+1]; x = x +1; } r->size--; return true; } //stores info into roster from file void getKittenFromFile(string str, struct roster& r) { ifstream myfile; string line; myfile.open(str); kitten temp; if (!myfile.is_open()) { cout size=0; myfile; r->size++) while (!myfile.eof()) { getline(myfile, line); temp.name = line; getline(myfile, line); temp.color = line; getline(myfile,line); temp.score = stoi(line); addKitten(temp, r); } myfile.close(); } //r ->size++; //myfile.close();

//updating kitten bool updateKitten(struct kitten* k, struct roster* r) { int x = findKitten(k->name,r); if(x == -1) { return false; } r -> kittens[x] = *k; return true; } //saves kitten into text file void printToFile(string str, struct roster* r) { ofstream myfile; myfile.open(str.c_str()); myfile size; i++) { myfile kittens[i].name kittens[i].color kittens[i].score size; i++) cout kittens[i].name kittens[i].color kittens[i].score

However, I'm only getting a 7/10 on passing the tests. I keep getting the following errors.

image text in transcribedimage text in transcribed

4: Unit test-deleteKitten() 0/10 Test deleting a kitten from roster Compilation failed main.cpp: In function 'bool test Passed (std::ofstream&)': main.cpp:65:28: error: cannot convert roster' to 'roster*' 65 | deleteKitten (kit3.name, kittenRoster); Compilation failed roster main.cpp:12:47: note: initializing argument 2 of 'bool deletekitten (st 12 | bool deletekitten (string name, struct roster* r); 5: Unit test - updateKitten() ^ 0/10 Test updating a kitten cuteness and score in the roster Compilation failed main.cpp: In function "bool test Passed (std::ofstream&)': main.cpp:70:17: error: cannot convert 'kitten' to 'kittent' 70 L updateKitten (update, kittenRoster); Compilation failed kitten main.cpp:15:34: note: initializing argument 1 of "bool updateKitten (k: 15 | bool updateKitten (struct kitten* k, struct roster* r)

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

Mastering Real Time Analytics In Big Data A Comprehensive Guide For Everyone

Authors: Lennox Mark

1st Edition

B0CPTC9LY9, 979-8869045706

More Books

Students also viewed these Databases questions

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago