C++, please edit my code so that I pass all the test cases. I posted the instructions. At the bottom, I posted the errors I am getting as well as the code I already have. Will upvote.
Code I already have:
#include #include #include using namespace std; struct kitten { string name,color; int score; }; struct roster { struct kitten kittens[10]; int size=0; }; void printMenu() { coutsize; i++) { if(ros->kittens[i].name == str) { coutkittens[i].namekittens[i].colorkittens[i].scoresize>=10) { coutsize++; ros->kittens[ros->size]=*kit; coutsize-1) { ros->kittens[index] = ros->kittens[index+1]; } ros->size--; return true; } bool updateKitten(struct kitten* kit, struct roster* ros) { int index = findKitten(kit->name,ros); if(index == -1) { return false; } ros->kittens[index] = *kit; return true; } void printRoster(struct roster* ros) { coutsize; i++) { coutkittens[i].namekittens[i].colorkittens[i].scoresize=0; myfile; ros->size++) { if(!myfile.eof()) { myfile>>ros->kittens[ros->size].name; myfile>>ros->kittens[ros->size].color; myfile>>ros->kittens[ros->size].score; } else break; } ros->size++; } void printToFile(string str, struct roster* ros) { ofstream myfile; myfile.open(str.c_str()); myfilesize; i++) myfilekittens[i].namekittens[i].colorkittens[i].score>ch; switch(ch) { case 'a' : cout>kit.name; cout>kit.color; cout>kit.score; addKitten(&kit,&kittenRoster); break; case 'd' : if (kittenRoster.size == 0) { cout>kit.name; bol = deleteKitten(kit.name,&kittenRoster); if(bol == false) cout>kit.name; cout>kit.color; cout>kit.score; bol = updateKitten(&kit,&kittenRoster); if(bol) cout>kit.name; index = findKitten(kit.name,&kittenRoster); if (index == -1) cout>name; getKittenFromFile(name,&kittenRoster); break; case 's' : cout>name; printToFile(name,&kittenRoster); break; case 'o' : printRoster(&kittenRoster); break; case 'q' : loop = 0; break; default: cout 15.3 Homework 3 This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens. You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a struct roster. This struct should contain the following attributes: kittens: an array of struct kitten, with size 10 size; int. This variable will be updated based on the current number of kittens in the roster. In main(), create a roster called kittenRoster. This will store your kitten roster. (3) Implement function printMenu(). This function prints out a menu of options for the user to modify the roster. Each option is represented by a single character. Ex: MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten - Load kitten info from file - Save kitten info to file 0 - Output roster q - Quit 0 Choose an option: After creating a roster from file, the program outputs the menu. The program will continue to output the menu, until the user chooses the option Quit. If user chooses an option that doesn't exist, display error message Invalid option. Please try again. You can safely assume that user will only enter lower-case letters for option. (4) Implement a function findkitten(). This function takes two arguments: a string name, and a roster struct. If the kitten's name is in the roster, return the position of the kitten in roster. Otherwise, return -1. (5) Implement a function addKitten(). This function takes two arguments: a kitten struct and a roster struct. If the roster is full, display error message Impossible to add new kitten: roster is full. Otherwise, it will add the new kitten to the end of the roster and display the message. The size of the roster will be updated accordingly. Successfully added new kitten to roster. (6) Implement function deletekitten(). This function takes string name and a roster struct as arguments. It deletes kitten with the same name in roster (i.e., remove the kitten from the roster). You can use findKitten() to check if the kitten exists in the roster. If kitten is not found, return false. Otherwise, delete the kitten, and return false. Remember to update the size of the roster accordingly and pay attention not to leave unused spaces in the roster array. (7) Implement function getKitten FromFile(). This function takes two arguments: the name of a file that stores kitten info, and a struct roster The function reads the file, and stores kittens info into roster. The format of the file is as follows a sample text file is provided as an example): If the file is not opened successfully, print Error! File not found. You can assume that the number of kittens in the file will not exceed the size of the array. This function will be tested using unit testing. (8) Implement updateKitten() function. This function takes 2 arguments: a kitten struct, and a roster struct. First, it needs to look up the kitten name in the roster (You can use findKitten() to look up kitten's name). If not found, return false. If found, update the corresponding kitten's color and cuteness score, and return true. (9) Implement print ToFile() function. This function takes a string filename, and a roster as arguments, saves the roster into a text file with the following format: ROSTER Kitten 1 -- Name: Peanut Butter, Color: light brown, Score: 10 Kitten 2 -- Name: Addie, Color: grey, Score: 42 (10) Implement a function printRoster(). This function takes as argument a roster and prints all the kittens info to standard output, each one on a new line. Ex: ROSTER Kitten 1 -- Name: Willow, Color: white, Score: 10 Kitten 2 -- Name: Addie, Color: grey, Score: 42 This function will be called when the user selects option 'o'. (11) Implement the "Add kitten" menu option. Prompt the user for a new kitten's name, color and score. Ex: Enter a new kitten's name: Rocky Balboa Enter the kittens's color: white Enter the kittens's cuteness score: 82 Store the user input into a kitten struct, then use addKitten() function to add the new kitten to roster. Note that the kitten's name may contain spaces. (12) Implement option "Delete kitten". If the user chooses the option when the roster is empty, immediately print the message: Cannot delete from empty roster. If the roster is not empty, prompt the user for a kitten's name. Remove the kitten with the specified name from the roster using deletekitten Enter kitten name to delete: Rocky Balboa If deletekitten() returns false (i.e. kitten is not in the roster), inform the user: Error! Kitten not found. (13) Implement the "Update kitten color and cuteness score" menu option, Prompt the user for a kitten's name, color and score. Ex: Enter a kitten name: Jingle Bell Enter a new color for the kitten: Pink Enter a new cuteness score for the kitten: 98 Call updateKitten(). If update unsuccessful, print the following error message: Cannot find kitten. Otherwise, display message: Otherwise, display message: Successfully updated kitten info. (14) Implement "Find kitten" menu option. Prompt the user for kitten's name. Ex: Enter a kitten name: Grump Kit Use findKitten(). If kitten is not found, print the following error message: Kitten not found. Otherwise, print out kitten info in the following format: kittenName info: color, cuteness score (15) Implement option "Load kitten info from file". Prompt the user for input file name. Enter file name: Use getKitten FromFile(). (16) Implement option "Save kitten info to file". Prompt the user for output file name. Enter file name: Use printToFile(). 1: Unit test -struct kitten ^ 10 / 10 Test struct kitten 2: Unit test -struct roster ^ 10 / 10 Test struct roster 3: Unit test - addKitten( ^ 0/10 Test adding a kitten to a roster Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&)': main.cpp:121:14: error: cannot convert 'kitten' to 'kittent' 121 addKitten (newkit, kittenRoster); A~~~~~ Compilation failed kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) 4: Unit test-deletekitten() ~ 0 / 10 Test deleting a kitten from roster Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&)': main.cpp:135:14: error: cannot convert 'kitten' to 'kittent' 135 | addKitten (kiti, kittenRoster); ^~ kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) main.cpp:136:14: error: cannot convert 'kitten' to 'kittent' 136 | addKitten (kit2, kittenRoster); ^~ kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kitten* kit, struct rostert ros) main.cpp:137:14: error: cannot convert 'kitten' to 'kittent' 137 | addKitten (kitu, kittenRoster); Compilation failed kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) Compilation failed kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kitten* kit, struct rostert ros) main.cpp:138:14: error: cannot convert 'kitten' to 'kittent' 138 L addKitten (kit4, kittenRoster); - kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) main.cpp:140:28: error: cannot convert roster' to 'rostert' 140 delete Kitten (kit3.name, kittenRoster); roster main.cpp:43:46: note: initializing argument 2 of 'bool deleteKitten (st 43 | bool deleteKitten (string name, struct rostert ros) ~~~~~~~~~~~ ~ ~~ 5: Unit test - updateKitten() ^ 0 / 10 Test updating a kitten cuteness and score in the roster Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&)': main.cpp:135:14: error: cannot convert 'kitten' to 'kittent' Test updating a kitten cuteness and score in the roster Compilation failed main.cpp: In function 'bool testPassed (std::ofstream&)': main.cpp:135:14: error: cannot convert 'kitten' to 'kittent' 135 L addKitten (kiti, kittenRoster); kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) main.cpp:136:14: error: cannot convert 'kitten' to 'kittent' 136 | addKitten (kit2, kittenRoster); kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) main.cpp:137:14: error: cannot convert 'kitten' to 'kittent' 137 | addKitten (kit3, kittenRoster); Ann Compilation failed kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kittent kit, struct rostert ros) main.cpp:138:14: error: cannot convert "kitten' to 'kittent' 138 addKitten (kit, kittenRoster); Compilation failed kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kitten* kit, struct rostert ros) main.cpp:138:14: error: cannot convert 'kitten' to 'kittent' 138 L addKitten (kit4, kittenRoster); kitten main.cpp:32:31: note: initializing argument 1 of 'void addKitten (kitte 32 | void addKitten (struct kitten* kit, struct rostert ros) main.cpp:145:17: error: cannot convert 'kitten' to 'kittent' 145 | updateKitten (update, kittenRoster); Aven kitten main.cpp:55:34: note: initializing argument 1 of 'bool updateKitten (k: 55 | bool updateKitten (struct kittent kit, struct rostert ros) Unit test - getkittenFromFile() ^ 0 / 10 Test loading kitten info from file (kitten Test.txt) Compilation failed main.cpp: In function "bool testPassed (std::ofstream&)': minan 115 orror Annot Tort Tractor to retort! 7: Test find Kitten ^ Simba yellow 98 Input Pepe Simba MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file O - Output roster q - Quit Choose an option: Enter a new kitten's name: Enter the kittens's color: Enter the kittens's cuteness score: Successfully added new kitten to roster. 0410 0 MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file 0 - Output roster q - Quit Your output does not contain Choose an option: Enter a kitten name: Kitten not found. MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file 0 - Output roster q - Quit Choose an option: Enter a new kitten's name: Enter the kittens's color: Enter the kittens's cuteness score: Successfully added new kitten to roster. MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file 0 - Output roster q - Quit Choose an option: Enter a new kitten's name: Enter the kittens's color: Enter the kittens's cuteness score: Enter the kittens's cuteness score: Successfully added new kitten to roster. MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file O - Output roster q - Quit Your output does not contain Choose an option: Enter a new kitten's name: Enter the kittens's color: Enter the kittens's cuteness score: Successfully added new kitten to roster. MENU a - Add kitten d - Delete kitten u - Update kitten color and cuteness score f - Find kitten 1 - Load kitten info from file S - Save kitten info to file 0 - Output roster q - Quit OnSpring2020 Choose an option: ROSTER: 9: Test adding more than 10 kittens and output roster ^ 0/10 Results hidden by your instructor 10: Test of printToFile() ~ 0 / 10 Your output ROSTER Kitten 1 -- Name: Pancho, Color: gray, Score 7 Kitten 2 -- Name: Simba, Color: yellow, Score 92 Kitten 3 -- Name: Romeo, Color: light, Score 0 Kitten 4 -- Name: , Color: , Score 0 Your output does not contain ROSTER: Kitten 1 -- Name: Pancho, Color: gray, Score: 7 Kitten 2 -- Name: Simba, Color: yellow, Score: 92 Kitten 3 -- Name: Romeo, Color: light blue, Score: 88 Kitten 4 -- Name: Chiquis, Color: purple, Score: 76 Kitten 5 -- Name: Panfi, Color: black, Score: 22