File : Celebrate .java public interface Celebrate { void fireworks(); } File : G
ID: 3555942 • Letter: F
Question
File : Celebrate .java
public interface Celebrate {
void fireworks();
}
File : Game.java
public interface Game {
void coinToss(Team team1, Team team2);
void startGame(Team team1, Team team2);
}
File : Team.java
public interface Team extends Sports {
String getName();
void setName(String name);
int getNumberOfPlayers();
void winToss(boolean win);
}
File : Sports.java
public interface Sports {
int getScore();
void setScore(int score);
}
File : PlayGame,java
public class PlayGame implements Game {
@Override
public void coinToss(Team team1, Team team2) {
// TODO Auto-generated method stub
}
@Override
public void startGame(Team team1, Team team2) {
// TODO Auto-generated method stub
}
public PlayGame(){
}
public static void main(String args[]){
}
public void simulateMatchUp(){
}
public String getVisitingTeamName() {
String teamName = null;
//add your logic
return teamName;
}
public String getHomeTeamName() {
String teamName = null;
//add your logic
return teamName;
}
public int genScore(Team team){
int score = 0;
//add your logic
return score;
}
}
File : NFL.java
public class NFL implements Celebrate, Team {
private String name;
private int numberOfPlayers;
private int score;
private boolean winToss;
@Override
public int getScore() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setScore(int score) {
// TODO Auto-generated method stub
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
@Override
public int getNumberOfPlayers() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void winToss(boolean win) {
// TODO Auto-generated method stub
}
@Override
public void fireworks() {
// TODO Auto-generated method stub
}
public NFL(){
}
public void kickOff(){
}
}
File : NBA.java
public class NBA implements Team {
private String name;
private int numberOfPlayers;
private int score;
private boolean winToss;
@Override
public int getScore() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setScore(int score) {
// TODO Auto-generated method stub
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setName(String name) {
// TODO Auto-generated method stub
}
@Override
public int getNumberOfPlayers() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void winToss(boolean win) {
// TODO Auto-generated method stub
}
public NBA(){
}
public void faceOff(){
}
}
How It Should Compile Like
Explanation / Answer
Note: The given program is a template for running the cod provided. For a real time application a lot of modifications needs to be done to the original code. It is not clear if that is allowed according to the assignment.
Program Code:
import java.util.Scanner;
public class GameWithToss
{
public static void main(String args[])
{
int ch;
String yn;
System.out.println("Welcome to Game Day Simulation!");
do
{
System.out.println("Pick you sport- Enter (1) for NFL (2) for NBA (3) for Cricket");
Scanner sc=new Scanner(System.in);
ch=sc.nextInt();
switch(ch)
{
case 1:
NFL nfl=new NFL();
System.out.println("Enter visiting team:");
String visit1=sc.next();
nfl.setName(visit1);
System.out.println("Enter home team:");
String home1=sc.next();
nfl.setName(home1);
break;
case 2:
NBA nba=new NBA();
System.out.println("Enter Visiting Team Name!");
String visit2=sc.next();
System.out.println("Enter home team:");
String home2=sc.next();
break;
case 3:
PlayGame pg=new PlayGame();
break;
default:
break;
}
System.out.println("Do you want to play again:");
yn=sc.next();
}
while(yn.equals("Y")||yn.equals("y"));
System.out.println("Thanks for playing, Bye!!");
}
}
class NFL implements Celebrate, Team
{
private String name;
private int numberOfPlayers;
private int score;
private boolean winToss;
public int getScore()
{
int score;
score=(int) Math.random()%100;
return score;
}
public void setScore(int score)
{
score=this.score;
}
public String getName()
{
return name;
}
public void setName(String name)
{
name=this.name;
}
public int getNumberOfPlayers()
{
return 0;
}
public void winToss(boolean win)
{
int win1=(int) (Math.random()%2);
if(win1==0)
this.winToss=false;
else
this.winToss=true;
}
public void fireworks()
{
}
public NFL()
{
}
public void kickOff()
{
}
}
class NBA implements Team
{
private String name;
private int numberOfPlayers;
private int score;
private boolean winToss;
@Override
public int getScore()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public void setScore(int score)
{
// TODO Auto-generated method stub
}
@Override
public String getName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setName(String name)
{
// TODO Auto-generated method stub
}
@Override
public int getNumberOfPlayers()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public void winToss(boolean win)
{
// TODO Auto-generated method stub
}
public NBA()
{
}
public void faceOff()
{
}
}
class PlayGame implements Game
{
@Override
public void coinToss(Team team1, Team team2)
{
// TODO Auto-generated method stub
}
@Override
public void startGame(Team team1, Team team2)
{
// TODO Auto-generated method stub
}
public PlayGame()
{
}
public static void main(String args[])
{
}
public void simulateMatchUp()
{
}
public String getVisitingTeamName()
{
String teamName = null;
//add your logic
return teamName;
}
public String getHomeTeamName()
{
String teamName = null;
//add your logic
return teamName;
}
public int genScore(Team team)
{
int score = 0;
//add your logic
return score;
}
}
interface Game
{
void coinToss(Team team1, Team team2);
void startGame(Team team1, Team team2);
}
interface Celebrate
{
void fireworks();
}
interface Team extends Sports
{
String getName();
void setName(String name);
int getNumberOfPlayers();
void winToss(boolean win);
}
interface Sports
{
int getScore();
void setScore(int score);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.