Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA PROGRAM You will implement a class AFLMatch . An AFL match has two AFLTeams homeTeam and awayTeam , and the score attributes for each

JAVA PROGRAM

You will implement a class AFLMatch. An AFL match has two AFLTeams homeTeam and awayTeam, and the score attributes for each team. In an AFL match,each score can either be a goal worth 6 points, or a behind, worth 1 point. You will need to keep track of these separately, as in the number of homeGoals, the number of homeBehinds, the number of awayGoals, and the number of awayBehinds. This class will also contain main() method and another method to load the lineup.

You will implement this class, including getter and setter methods as appropriate.

Load in the lineups

To load the lineups of the two teams, you will accept as input at the command line the names of two files. The first filename will be the name of a file the home team's (MelbourneDemons.txt) lineup, and the second filename will be the name of a file containing the away team's lineup (WesternBulldogs.txt).

For example, you would start the program as:

> java AFLMatchMelbourneDemons.txt WesternBulldogs.txt

File names must be passed as arguments to the main method. This would load the home team's lineup from MelbourneDemons.txt, and the away team's lineup from WesternBulldogs.txt.

These files consist of name of team, COACH and 22 players (among them 1 is captain) details. Before the game starts load up both teams homeTeam and awayTeam. However, if the number of players is less than 22 in any team, a relevant error message should be printed, and match should not start.

Part VI: Run the game (20 marks)

You will use a loop to take input from the user, who is the "scorekeeper." This loop will prompt the user to type one letter to indicate which team scored: "h" for the home team or "a" for the away team. It will then prompt the user to type one letter to indicate the type of score: "g" for goal or "b" for behind. This loop will keep running until the user types "f", to indicate full time (the end of the match). In action, the loop might look like this:

Melbourne Demons 1.1 (7) defeated Western Bulldogs 1.0 (6).

For example, if current score is 1.10, it means 1 goal and 10 behind so final score would be

6+10=16.

Please supply screenshots of the output of your program.

Test Results for invalid input

Please supply screenshots for the output of your program for invalid input values - that is inputs other than "h", "a", "b", "g", or "f" entered in the scorekeeping loop.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

Students also viewed these Databases questions