Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

4) Create the following class. You will NOT need setters and getters for this. T

ID: 3750056 • Letter: 4

Question

4) Create the following class. You will NOT need setters and getters for this. There will however be 1 constructor as indicated. class BallGame string homeTeam string awayTeam; int homeScore; int awayScore BallGame(string hmTeam, string awTeam, int hmSc, int awSc); bool didHomeTeamWin0 You must implement the constructor and didHomeTeamWin() method. The method must return whether the home team has the larger score. (Note, a tie is not a win) In main Allocate memory for three separate BallGame instances and point to that memory with 3 separate pointer variables, game1, game2, and game3. Make each pointer represent the following data: "Mystics", "Fire", 100,92 "Capitals", "Lightning", 2,3 "Ravens", "Colts",35,35

Explanation / Answer

constructor: ------------ BallGame::BallGame(string hmTeam, string awTeam, int hmSc, int awSc) { homeTeam = hmTeam; awayTeam = awTeam; homeScore = hmSc; awayScore = awSc; } didHomeTeamWin method(): --------------------------- bool BallGame::didHomeTeamWin() { return homeScore > awayScore; } creating objects: -------------------- BallGame *game1 = new BallGame("Mystics", "Fire", 100, 92); BallGame *game2 = new BallGame("Capitals", "Lightning", 2, 3); BallGame *game3 = new BallGame("Ravens", "Colts", 35, 35);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote