C++ programming question, please help! Thank you so much in advance!!!
In this exercise, you will work with 2 classes to be used in a RPG videogame.
The first class is the class Character. The Character class has two string type properties: name and race. The Character class also has the following methods:
Character Name: <name> Character Race: <race>
The Character class is already implemented.
You will have to implement another class, called Wizard, which inherits from the Character class. The Wizard class has two attributes: an array of strings called listOfSpell and an integer amountOfSpell. The array of string is of fixed size 10, which is the maximum number of spells a Wizard can know. The amountOfSpell variable indicates how many spells the Wizard knows. The Wizard class has the following methods:
Wizard information: Character Name: <name> Character Race: <race> Spells: <spell1> <spell2> ...
When the Wizard class is complete, uncomment the main to complete all tests.
main.cpp:
#include <iostream>
//Add headers!
int main() {
// Uncomment when ready to test Wizard class
/*
string name, race, spell;
getline(cin,name);
getline(cin,race);
Wizard wiz(name,race);
getline(cin,spell);
int numberSpell=wiz.AddSpell(spell);
getline(cin,spell);
numberSpell = wiz.AddSpell(spell);
getline(cin,spell);
numberSpell = wiz.AddSpell(spell);
cout << "Wizard information:" << endl;
wiz.Print();
cout << "Number of spells available: " << numberSpell << endl;
int no;
cin >> no;
cout << "Spell casted: " << wiz.CastSpell(no) <<
endl;
*/
return 0;
}
character.h:
#ifndef CHARACTER_H
#define CHARACTER_H
#include <iostream>
#include <string>
using namespace std;
class Character {
private:
string name;
string race;
public:
Character(string name, string race);
void SetName(string name);
string getName() const;
void SetRace(string name);
string getRace() const;
void Print();
};
#endif
character.cpp:
#include <iostream>
#include "character.h"
using namespace std;
Character::Character(string Name,string Race){
name=Name;
race=Race;
}
void Character::SetName(string Name){
name=Name;
}
string Character::getName()const {
return name;
}
void Character::SetRace(string Race){
race=Race;
}
wizard.h:
#ifndef WIZARD_H
#define WIZARD_H
#include <iostream>
#include <string>
#include "character.h"
using namespace std;
class Wizard : public Character {
private:
//...
public:
//...
};
#endif
wizard.cpp:
#include <iostream>
#include "wizard.h"
using namespace std;
//Constructor:
//...
string Wizard::CastSpell(int num){
//...
}
int Wizard::AddSpell(string spell){
//...
}
void Wizard:: Print(){
//...
}
I’ve completed the Wizard class in wizard.h and wizard.cpp and also completed the remaining functions in character.cpp.
Run main.cpp, character.cpp and wizard.cpp simultaneously.
Code:
//main.cpp:
#include <iostream>
#include "character.h"
#include "wizard.h"
using namespace std;
int main() {
// Uncomment when ready to test Wizard class
string name, race, spell;
getline(cin,name);
getline(cin,race);
Wizard wiz(name,race);
getline(cin,spell);
int numberSpell=wiz.AddSpell(spell);
getline(cin,spell);
numberSpell = wiz.AddSpell(spell);
getline(cin,spell);
numberSpell = wiz.AddSpell(spell);
cout << "Wizard information:" << endl;
wiz.Print();
cout << "Number of spells available: " << numberSpell << endl;
int no;
cin >> no;
cout << "Spell casted: " << wiz.CastSpell(no) << endl;
return 0;
}
//character.h:
#ifndef CHARACTER_H
#define CHARACTER_H
#include <iostream>
#include <string>
using namespace std;
class Character {
private:
string name;
string race;
public:
Character(string name, string race);
void SetName(string name);
string getName() const;
void SetRace(string name);
string getRace() const;
void Print();
};
#endif
//character.cpp:
#include <iostream>
#include "character.h"
using namespace std;
Character::Character(string Name, string Race) {
name = Name;
race = Race;
}
void Character::SetName(string Name) {
name = Name;
}
string Character::getName() const {
return name;
}
void Character::SetRace(string Race) {
race = Race;
}
string Character::getRace() const {
return race;
}
void Character::Print() {
cout << "Character Name: " << this -> getName();
cout << "\tCharacter Race: " << this -> getRace() << endl;
}
//wizard.h:
#ifndef WIZARD_H
#define WIZARD_H
#include <iostream>
#include <string>
#include "character.h"
using namespace std;
class Wizard: public Character {
private:
string listOfSpells[10];
int amountOfSpells;
public:
Wizard(string name, string race);
int AddSpell(string spell);
string CastSpell(int num);
void Print();
};
#endif
//wizard.cpp:
#include <iostream>
#include "wizard.h"
using namespace std;
Wizard::Wizard(string name, string race):Character(name,race){
amountOfSpells = 0;
for(int i = 0; i < 10; i++)
listOfSpells[i] = "";
}
string Wizard::CastSpell(int num) {
return listOfSpells[num-1];
}
int Wizard::AddSpell(string spell) {
listOfSpells[amountOfSpells++] = spell;
return amountOfSpells;
}
void Wizard::Print() {
cout << "Wizard information: Character Name: " << this -> getName();
cout << "\tCharacter Race: " << this -> getRace() << endl;
cout << "Spells:" << endl;
for(int i = 0; i < amountOfSpells; i++)
cout <<"Spell " << i + 1 << ".\t" << listOfSpells[i] << endl;
cout << endl;
}
Output:
C++ programming question, please help! Thank you so much in advance!!! In this exercise, you will...
Greetings, everybody I already started working in this program. I just need someone to help me complete this part of the assignment (my program has 4 parts of code: main.cpp; Student.cpp; Student.h; StudentGrades.cpp; StudentGrades.h) Just Modify only the StudentGrades.h and StudentGrades.cpp files to correct all defect you will need to provide implementation for the copy constructor, assignment operator, and destructor for the StudentGrades class. Here are my files: (1) Main.cpp #include <iostream> #include <string> #include "StudentGrades.h" using namespace std; int...
CODES: main.cpp #include <iostream> #include <string> #include "ShoppingCart.h" using namespace std; char PrintMenu() { char answer; cout << "MENU" << endl; cout << "a - Add item to cart" << endl; cout << "d - Remove item from cart" << endl; cout << "c - Change item quantity" << endl; cout << "i - Output items' descriptions" << endl; cout << "o - Output shopping cart" << endl; cout << "q - Quit" << endl << endl; while (true) {...
C++ -- Vector of Bank Accounts (15 pts) Please help! :( Use csegrid or Clion for this part Add on to the lab12a solution(THIS IS PROVIDED BELOW). You will add an overload operator function to the operator << and a sort function (in functions.h and functions.cpp) Print out the customer’s name, address, account number and balance using whatever formatting you would like Sort on account balance (hint: you can overload the < operator and use sort from the...
I need help with this assignment, can someone HELP ? This is the assignment: Online shopping cart (continued) (C++) This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program). (1) Extend the ItemToPurchase class per the following specifications: Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0). (1 pt) Public member functions SetDescription() mutator & GetDescription() accessor (2 pts) PrintItemCost() - Outputs the item name followed by...
Write a C++ Program. You have a following class as a header file (dayType.h) and main(). #ifndef H_dayType #define H_dayType #include <string> using namespace std; class dayType { public: static string weekDays[7]; void print() const; string nextDay() const; string prevDay() const; void addDay(int nDays); void setDay(string d); string getDay() const; dayType(); dayType(string d); private: string weekDay; }; #endif /* // Name: Your Name // ID: Your ID */ #include <iostream>...
previous assignment code /*C++ test program to test the classes, Animal, Mammal and Cat and print the results on console window.*/ //Main.cpp //include header files #include<iostream> //include Animal, Mammal and Cat header files #include "Animal.h" #include "Mammal.h" #include "Cat.h" using namespace std; int main() { //create Animal object Animal animal("Dog","Mammal",4); cout<<"Animal object details"<<endl; cout<<"Name: "<<animal.getName()<<endl; cout<<"Type: "<<animal.getType()<<endl; cout<<"# of Legs: "<<animal.getLegs()<<endl; cout<<endl<<endl; //create Cat object Cat cat("byssinian cat","carnivorous mammal",4,"short...
Need to implement Account.cpp and AccountManager.cpp code //Account.hpp #ifndef _ACCOUNT_HPP_ #define _ACCOUNT_HPP_ #include <string> using std::string; class Account { public: Account(); Account(string, double); void deposit(double); bool withdraw(double); string getName() const; double getBalance() const; private: string name; double balance; }; #endif ////////////////////////////////////////////// //AccountManager.hpp #ifndef _ACCOUNT_MANAGER_HPP_ #define _ACCOUNT_MANAGER_HPP_ #include "Account.hpp" #include <string> using std::string; class AccountManager { public: AccountManager(); AccountManager(const AccountManager&); //copy constructor void open(string); void close(string); void depositByName(string,double); bool withdrawByName(string,double); double getBalanceByName(string); Account getAccountByName(string); void openSuperVipAccount(Account&); void closeSuperVipAccount(); bool getBalanceOfSuperVipAccount(double&) const;...
#ifndef PROCESSREQUESTRECORD_CLASS #define PROCESSREQUESTRECORD_CLASS #include <iostream> #include <string> using namespace std; class procReqRec { public: // default constructor procReqRec() {} // constructor procReqRec(const string& nm, int p); // access functions int getPriority(); string getName(); // update functions void setPriority(int p); void setName(const string& nm); // for maintenance of a minimum priority queue friend bool operator< (const procReqRec& left, const procReqRec& right); // output a process request record in the format // name: priority friend ostream& operator<< (ostream& ostr, const procReqRec&...
hello there. can you please help me to complete this code. thank you. Lab #3 - Classes/Constructors Part I - Fill in the missing parts of this code #include<iostream> #include<string> #include<fstream> using namespace std; class classGrades { public: void printlist() const; void inputGrades(ifstream &); double returnAvg() const; void setName(string); void setNumStudents(int); classGrades(); classGrades(int); private: int gradeList[30]; int numStudents; string name; }; int main() { ...