Solution to Create class called match; the class must have the following data members and methods: Data … - Sikademy
Author Image

Archangel Macsika

Create class called match; the class must have the following data members and methods: Data Members: •This class has two data members named HomeTeam and VisitorTeam which are of type Team, they will store that two teams that will play the Match. Methods: •This class doesn’t have a default constructor, it only has one constructor which receives two Team object that will be assigned to HomeTeam and VisitorTeam. •setTeams(),which receives two Team object that will be assigned to HomeTeam and VisitorTeam. •playMatch(), simulates match play by calling the scoreGoals methods of each team. •getPlayGound(), returns the ground of play which is the HomeGound of the HomeTeam. •isDrawMatch(), will return true if the Match is a draw and false if there is a winner. The match is a draw if the goals of the teams are equal. •getWinner(), returns the team which won the match, a team wins if its goals is higher than the goals of the other team.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question


#include <iostream> class Match { private: Team homeTeam; Team visitorTeam; public: public Match(Team a, Team b): homeTeam(a), visitorTeam(b) { } public setTeams(Team a, Team b) { this->homeTeam = a; this->visitorTeam = b; } void playMatch() { this->homeTeam.scoreGoals(); this->visitorTeam.scoreGoals(); } HomeGround getPlayGound() { return homeTeam.getGround(); } bool isDrawMatch() { return homeTeam.getGoals() == visitorTeam.getGoals(); } Team getWinner() { if (homeTeam.getGoals() > visitorTeam.getGoals()) { return homeTeam; } else { return visitorTeam; } } };

Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1066-qpid-62