soccerApp.cpp is used to test your code and contains the main function. No changes to this file are necessary.
Inside of the soccerPlayer.cpp file, implement the three member functions that are specified in
soccerPlayer.hpp. The member function definition for print is already provided.
soccerPlayer.cpp:
#include "soccerPlayer.hpp"
void TopTwoPlayer::print() const {
cout << left << setw(8) << "Name: " << setw(18) << name << setw(10) << "Country:" <<
setw(18) << country << setw(14) << "appearances:" << right << setw(3) << appearances <<
setw(4) << " " << left << setw(8) << "games:" << right << setw(3) << games << endl;
}
// Place your member function definitions here:
// 1: The constructor. Remember that you don't know how long the c-string arguments are.
// Use strncpy and null terminate.
// 2: Function definition for moreAppearances.
// 3: Function definition for moreGames.
soccerPlayer.hpp:
// Header file for lab 4.
#ifndef PLAYER_HPP
#define PLAYER_HPP
#include <iostream>
#include <iomanip>
#include <cstring>
using namespace std;
const int STR_SIZE = 100;
class TopTwoPlayer { // Soccer players with the most finishes in the top 2 teams.
char name[STR_SIZE];
char country[STR_SIZE];
int appearances; // How many times they played in a game.
int games; // The number of games where the player was on the team.
public:
void print() const; // Already implemented in soccerPlayer.cpp.
// Implement the following functions in soccerPlayer.cpp
TopTwoPlayer(const char nameArg[], const char countryArg[], int appearancesArg, int gamesArg);
bool moreAppearances(const TopTwoPlayer & otherPlayer) const;
bool moreGames(const TopTwoPlayer & otherPlayer) const;
};
#endif
soccerApp.cpp:
#include "soccerPlayer.hpp"
using namespace std;
int main() {
TopTwoPlayer player1("Birgit Prinz", "Germany", 18, 18); // Testing your constructor with arguments.
TopTwoPlayer player2("Christie Rampone", "United States", 9, 19);
cout << "\nTwo of the \"top two\" players: " << endl;
player1.print();
player2.print();
cout << endl;
if(player1.moreAppearances(player2)) { // Testing your moreAppearances code.
cout << "Great job on moreAppearances code!" << endl;
} else {
cout << "Hmm, moreAppearances code is not quite right." << endl;
}
if(player2.moreGames(player1)) { // Testing your moreGames code.
cout << "Great job on moreGames code!" << endl;
} else {
cout << "Hmm, your moreGames code is not quite right." << endl;
}
return 0;
}
//Please like and comment
soccerPlayer.cpp
TopTwoPlayer::TopTwoPlayer(const char nameArg[], const char
countryArg[], int appearancesArg, int gamesArg)
{
strncpy(name, nameArg, strlen(nameArg) + 1);
strncpy(country, countryArg, strlen(countryArg) +
1);
appearances = appearancesArg;
games = gamesArg;
}
// 2: Function definition for moreAppearances.
bool TopTwoPlayer::moreAppearances(const TopTwoPlayer &
otherPlayer) const
{
return appearances >=
otherPlayer.appearances;
}
// 3: Function definition for moreGames.
bool TopTwoPlayer::moreGames(const TopTwoPlayer &
otherPlayer) const
{
return games >= otherPlayer.games;
}
output

soccerApp.cpp is used to test your code and contains the main function. No changes to this...
Can somebody help me with this coding the program allow 2 players play tic Tac Toe. however, mine does not take a turn. after player 1 input the tow and column the program eliminated. I want this program run until find a winner. also can somebody add function 1 player vs computer mode as well? Thanks! >>>>>>>>>>>>>Main program >>>>>>>>>>>>>>>>>>>>>>> #include "myheader.h" int main() { const int NUM_ROWS = 3; const int NUM_COLS = 3; // Variables bool again; bool won;...
You are given a Q1.h file with overloaded function prototypes
for isOrdered. Implement this overloaded function into a file named
Q1.cpp. Q1.cpp should only include your function implementation,
the necessary #include directives if needed, and should not contain
anything else such as the main function or global variable
declarations. Test your code using a separate main.cpp file where
you implement a sufficient number of test cases. You should use
Q1.h as a header file and Q1main.cpp as a main function...
For the LinkedList class, create a getter and setter for the private member 'name', constructing your definitions based upon the following declarations respectively: std::string get_name() const; and void set_name(std::string); In the Main.cpp file, let's test your getter and setter for the LinkedLIst private member 'name'. In the main function, add the following lines of code: cout << ll.get_name() << endl; ll.make_test_list(); ll.set_name("My List"); cout << ll.get_name() << endl; Output should be: Test List My List Compile and run your code;...
I need assistance with the C++ code below to remove the "this" pointers while maintaining the code's current output and functionality. Also, there should be a private class in the header file, but I'm not sure what I should include there. Any help would be greatly appreciated! ***main.cpp driver file*** #include <iostream> #include "vector.h" using namespace std; int main() { vectorInfo v1(7, 6); vectorInfo v2(5, 4); v1.set(3, 2); cout << "v1 : "; v1.print(); cout << "v2 :...
Code in C++: Please help me fix the error in function: void write_account(); //function to write record in binary file (NOTE: I able to store data to a txt file but however the data get error when I try to add on data the second time) void display_all(); //function to display all account details (NOTE: This function is to display all the info that save account.txt which is ID, Name, and Type) void modify_account(int); //function to modify record of file...
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...
I cannot get the C++ code below to compile correctly. Any assistance would be greatly appreciated! ***main.cpp driver file*** #include #include #include "vector.h" using namespace std; int main() { vectorInfo v1(3, -1); vectorInfo v2(2, 3); cout << "v1 : "; v1.print(); cout << "v2 : "; v2.print(); cout << "v1 magnitude : " << v1.magnitude() << endl; cout << "v1 direction : " << v1.direction() << " radians" << endl; cout...
Please help fix my code C++, I get 2 errors when running. The code should be able to open this file: labdata.txt Pallet PAG PAG45982IB 737 4978 OAK Container AYF AYF23409AA 737 2209 LAS Container AAA AAA89023DL 737 5932 DFW Here is my code: #include <iostream> #include <string> #include <fstream> #include <vector> #include <cstdlib> #include <iomanip> using namespace std; const int MAXLOAD737 = 46000; const int MAXLOAD767 = 116000; class Cargo { protected: string uldtype; string abbreviation; string uldid; int...
Requirements I have already build a hpp file for the class architecture, and your job is to implement the specific functions. In order to prevent name conflicts, I have already declared a namespace for payment system. There will be some more details: // username should be a combination of letters and numbers and the length should be in [6,20] // correct: ["Alice1995", "Heart2you", "love2you", "5201314"] // incorrect: ["222@_@222", "12306", "abc12?"] std::string username; // password should be a combination of letters...
2 The following code has some errors. Please point out and correct them (there might be more than 1 errors). Note: the use of const data member increment and member function print. // This code has some errors. #include using namespace std; class Increment { public: Increment( int c = 0, int i = 0); void addIncrement() const { count -= increment }; void print() const; private: int count; const int increment; }; Increment::Increment(int c, int i) { cout =...