Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hey, I've made a program but im stuck somewhere and I don't know how I can fix it. class Match { private Boolean homeHasWon; private
Hey, I've made a program but im stuck somewhere and I don't know how I can fix it.
class Match { private Boolean homeHasWon; private Team home; private Team visiting; public Match(Team home, Team visiting, Boolean homeHasWon) { this.home = home; this.visiting = visiting; this.homeHasWon = homeHasWon; } public Team getHome() { return home; } public Team getVisiting() { return visiting; } public Boolean getHomeHasWon() { return homeHasWon; } public String heldInCity() { return } public String nameWinner() { return } } class Team { private String name; private String city; private Coach coachedBy; public Team(String name, String city, Coach coachedBy) { this.name = name; this.city = city; this.coachedBy = coachedBy; } public String getName() { return name; } public String getCity() { return city; } public Coach getCoachedBy() { return coachedBy; } } class Coach { private String name; public Coach(String name) { this.name = name; } public String getName() { return name; } } class Main { public static void main(String[] args) { Coach dick = new Coach("Dick Advocaat"); Coach erik = new Coach("Erik ten Hag"); Coach mark = new Coach("Mark van Bommel"); Team ajax = new Team("Ajax", "Amsterdam", erik); Team feyenoord = new Team("Feyenoord", "Rotterdam", dick); Team psv = new Team("PSV", "Eindhoven", mark); Match match1 = new Match(ajax, psv, true); Match match2 = new Match(psv, feyenoord, false); System.out.println("De winnaar van 'match1' was: " + match1.nameWinner()); System.out.println("Deze wedstrijd werd gespeeld in: " + match1.heldInCity()); System.out.println("De winnaar van 'match2' was: " + match2.nameWinner()); System.out.println("Deze wedstrijd werd gespeeld in: " + match2.heldInCity()); } }
I have no clue how to access methods in other classes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started