Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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: Which team scored? h Goal or behind? b The current score is 0.1 (1) to 0.0 (0). Which team scored? a Goal or behind? g The current score is 0.1 (1) to 1.0 (6). Which team scored? h Goal or behind? g The current score is 1.1 (7) to 1.0 (6). Which team scored? f FULL TIME Melbourne Demons 1.1 (7) defeated Western Bulldogs 1.0 (6)

Part VII: Add exceptions and exception handling (20 marks) At this point, you have a program that "works", but isn't really complete. For example, you could put in a negative number for a player's number, or you could list someone at a position other than COACH as the team's coach, or your lineup can have more or less than 22 players. All of these should be illegal, but our program doesn't handle any of these cases yet. These are all examples of run-time problems, which should throw exceptions when they occur. You will modify your program to define appropriate Exception types, throw them at appropriate types, and handle them in appropriate places in your code. Specifically, you should check for the following problems in your program: - A filename that is invalid (does not correspond to an existing file of the appropriate format) - A player who has a number that is invalid (negative or not an integer) - A team member who has an invalid position - A team that has more or fewer than eighteen players - A team that has more or fewer than one captain - A value other than "h", "a", "b", "g", or "f" is 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions