im almost done i just need help to get the output Chapter 5

im almost done i just need help to get the output.

Chapter 5, PP 7 Java Project Name: IC17_FootballGame

Create a class named FootballGame that contains information about a game played between two teams. The FootballGame class has the following instance variables (a.k.a. fields or data):

homeTeam (String)
visitorTeam (String)
homeScore (int)
visitorScore (int)

The FootballGame class will have methods to:

Create a new  FootballGame (given a homeTeam and visitorTeam only - score should be 0 and 0) [parameterized constructor]

getHomeScore()
getVisitorScore()

scoreTouchdown(String teamName) - adds 6 points to the appropriate team (home or visitor). Returns true if the teamName equals either  homeTeam or visitorTeam , false otherwise.
scoreExtraPoint(String  teamName) - adds 1 point to the appropriate team (home or visitor). Returns true if the teamName equals either  homeTeam or visitorTeam , false otherwise.
scoreConversion(String  teamName) - adds 2 points to the appropriate team (home or visitor). Returns true if the teamName equals either  homeTeam or visitorTeam , false otherwise.
scoreFieldGoal(String  teamName) - adds 3 points to the appropriate team (home or visitor). Returns true if the teamName equals either  homeTeam or visitorTeam , false otherwise.  
scoreSafety(String  teamName) - adds 2 points to the appropriate team (home or visitor). Returns true if the teamName equals either  homeTeam or visitorTeam , false otherwise.   

equals - method to check if one FootballGame is the same as another by comparing all instance variables for equality.
toString - method to turn a FootballGame into a string for display, e.g. display as \"FootballGame [LA Rams=6, NY Giants=0 ~~~ Home Team is Winning]\" (assume the LA Rams were the home team in this game)

Below is a class diagram showing the fields and methods of the FootballGame class.

After you complete the class, please create a driver class (called FootballGameDemo) that tests the FootballGame class just created. For example, the demo should print:

Please enter home team name: LA Rams

Please enter visitor team name: NY Giants

Enter Scoring Event (or -1 to end game):
1) To score touchdown
2) To score extra point
3) To score conversion
4) To score field goal
5) To score safety

>>1

Enter Team:

1) For LA Rams (home)
2) For NY Giants (visitor)

>> 1

FootballGame [LA Rams=6, NY Giants=0 ~~~ Home Team is Winning]

Enter Scoring Event (or -1 to end game):
1) To score touchdown
2) To score extra point
3) To score conversion
4) To score field goal
5) To score safety

>>1

Enter Team:

1) For LA Rams (home)
2) For NY Giants (visitor)

>> 2

FootballGame [LA Rams=6, NY Giants=6 ~~~ It\'s a Tie]  

Enter Scoring Event (or -1 to end game):
1) To score touchdown
2) To score extra point
3) To score conversion
4) To score field goal
5) To score safety

>>4

Enter Team:

1) For LA Rams (home)
2) For NY Giants (visitor)

>> 2

FootballGame [LA Rams=6, NY Giants=9 ~~~ Visiting Team is Winning]

public class FootballGame

{

private String mHomeTeam;

private String mVisitorTeam;

private int mHomeScore;

private int mVisitorScore;

  

public FootballGame (String newHomeTeam, String newVisitorTeam)

{

mHomeTeam = newHomeTeam;

mVisitorTeam = newVisitorTeam;

mHomeScore = 0;

mVisitorScore = 0;

}

  

public int getHomeScore()

{

return mHomeScore;

}

public int getVisitorScore()

{

return mVisitorScore;

}

  

public void scoreTouchdown(String teamName)

{

if(teamName.equalsIgnoreCase(mHomeTeam))

mHomeScore += 6;

if(teamName.equalsIgnoreCase(mVisitorTeam))

mVisitorScore += 6;

}

public void scoreExtraPoint(String teamName)

{

if(teamName.equalsIgnoreCase(mHomeTeam))

mHomeScore += 1;

if(teamName.equalsIgnoreCase(mVisitorTeam))

mVisitorScore += 1;

}

public void scoreFieldGoal(String teamName)

{

if(teamName.equalsIgnoreCase(mHomeTeam))

mHomeScore += 3;

if(teamName.equalsIgnoreCase(mVisitorTeam))

mVisitorScore += 3;

}

public void scoreSafety(String teamName)

{

if(teamName.equalsIgnoreCase(mHomeTeam))

mHomeScore += 2;

if(teamName.equalsIgnoreCase(mVisitorTeam))

mVisitorScore += 2;

}

public void scoreConversion(String teamName)

{

if(teamName.equalsIgnoreCase(mHomeTeam))

mHomeScore += 2;

if(teamName.equalsIgnoreCase(mVisitorTeam))

mVisitorScore += 2;

}

@Override

public int hashCode()

{

final int prime = 31;

int result = 1;

result = prime * result + mHomeScore;

result = prime * result + ((mHomeTeam == null) ? 0 : mHomeTeam.hashCode());

result = prime * result + mVisitorScore;

result = prime * result + ((mVisitorTeam == null) ? 0 : mVisitorTeam.hashCode());

return result;

}

@Override

public boolean equals(Object obj)

{

if (this == obj) return true;

if (obj == null) return false;

if (getClass() != obj.getClass()) return false;

FootballGame other = (FootballGame) obj;

if (mHomeScore != other.mHomeScore) return false;

if (mHomeTeam == null)

{

if (other.mHomeTeam != null) return false;

}

else if (!mHomeTeam.equals(other.mHomeTeam)) return false;

if (mVisitorScore != other.mVisitorScore) return false;

if (mVisitorTeam == null)

{

if (other.mVisitorTeam != null) return false;

}

else if (!mVisitorTeam.equals(other.mVisitorTeam)) return false;

return true;

}

@Override

public String toString()

{

return \"FootballGame [mHomeTeam=\" + mHomeTeam + \", mVisitorTeam=\" + mVisitorTeam + \", mHomeScore=\" + mHomeScore

+ \", mVisitorScore=\" + mVisitorScore + \"]\";

}

  

  

}

now i just need help from the demo please help.

import java.util.Scanner;

public class FootballGameDemo

{

public static void main(String[] args)

{

String homeTeam;

String visitorTeam;

Scanner consoleScanner = new Scanner(System.in);

  

System.out.print(\"Please enter home team name: \");

System.out.println();

homeTeam = consoleScanner.nextLine();

System.out.print(\"Please enter a visitor team name: \");

visitorTeam = consoleScanner.nextLine();

  

FootballGame game1 = new FootballGame(homeTeam, visitorTeam);

  

int option;

do{System.out.println(\"Enter Scoring Event (or -1 to end game)\");

System.out.println(\"1) to score touchdown\");

System.out.println(\"2) to score extra point\");

System.out.println(\"3) to score conersion\");

System.out.println(\"4) to score field goal\");

System.out.println(\"5) to score safety\");

  

option = consoleScanner.nextInt();

switch(option)

{

case 1:

System.out.print(\"Enter Team: \");

System.out.println();

System.out.println();

System.out.println(\"1) for \" + homeTeam + \" (home)\");

System.out.println(\"2) for \" + visitorTeam + \" (visitor)\");

  

option = consoleScanner.nextInt();

  

String teamName = consoleScanner.nextLine();

game1.scoreTouchdown(teamName);

break;

  

}

  

  

}while(option != -1);

  

  

  

}

}

if you can figure out the rest that will be really helpful!

Solution

It\'s generally a good idea to use extra parentheses when using complex macros. Notice that in the above example, the variable \"x\" is always within its own set of parentheses. This way, it will be evaluated in whole, before being compared to 0 or multiplied by -1. Also, the entire macro is surrounded by parentheses, to prevent it from being contaminated by other code. If you\'re not careful, you run the risk of having the compiler misinterpret your code.

Because of side-effects it is considered a very bad idea to use macro functions as described above.

im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat
im almost done i just need help to get the output. Chapter 5, PP 7 Java Project Name: IC17_FootballGame Create a class named FootballGame that contains informat

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site