Question

Moe's score is 20 Curly's score is 40 Section 4: Derived Class Results: Baseball scoring The scores for Cubs vs Braves: Cubs's score is 2 Braves's score is 3 The current

inning is 1.5 Outs: 1 Strikes: 2 Fouls: 3 Balls: 1 Directions for Submitting Your Assessment The source code file is the file in your project that contains the code you wrote. You will only need to submit the source code file for your program and not the entire project folder or any additional project files. Below are listed the file extensions for the source code file for each language: .cs file for C# java file for Java .php and .js files for Web Development Naming Your Project and Source Code File While you can change your file name later, it will be simpler with less chance of confusion if you name your new project and code file with the following naming convention when you create it. The code files should be saved as: IT232_YourLastName_M5. The source code file and the project name can be the same./nSection 4: 1. Enter the comment with the section title as described above. 2. Write code to test the sub-class. This can be done multiple ways and should be when thoroughly testing your code. However, for this Assessment's output, we will use the following method: a. Print "Section 4: Derived Class Results: Baseball scoring" to the console followed by a blank line. b. Instantiate an object called gameTwo, from the baseball class, passing "Cubs" and "Braves" as the teams, (or teams of your choosing), to the constructor. (Note: If you choose to use different team names, be sure you substitute them below for 'Cubs' or 'Braves'. c. The following method calls should be done in order to guarantee the correct results. i. ii. iii. iv. V. vi. vii. viii. ix. Call the addScore() method to advance the Cubs' score by 2. Call the advOuts() method three times. Call the addScore() method to advance the Braves' score by 3. Call the advOuts() method once. Call the advStrikes() method once. Call the advFouls() method thrice. Call the advBalls() method once. Call the listAllScores() method to print the game and scores. Also, print a blank line to the console. Use the appropriate get methods to print the current inning, outs, strikes, fouls, and balls. EXPECTED OUTPUT Assessment 10 - Classes and Inheritance Section 3: Base Class Results After Adding The scores for Canasta: Larry's score is 20 Moe's score is 35 Curly's score is 45 Section 3: Base Class Results After Subtracting The scores for Canasta: Larry's score is 20/ng. Include a public method, advFouls(), to add one to the number of fouls. If the number of strikes is less than 2, advFouls() should also add one to strikes. i. h. Include a public method, getFouls(), to return the current number of fouls. Include a public method, advBalls(), to add one to the number of balls. If the number of balls reaches 4, reset balls, strikes and fouls. (This means the player has been given a walk to first base but does not guarantee and runs were scored. k. j. Include a public method, getBalls(), to return the current number of balls. Include a public method, getInning(), to return the current inning. Include two constructors. The first one is a default constructor. The second is a constructor method which will accept the name of the home team followed by the name of the visiting team. It will then call the setGame() and pass it a combined name such as "Cubs vs Braves". It will also call the addName() method to add the two teams to the players property. I. Section 3: 1. Enter the comment with the section title as described above. 2. Write code to test the base class. This can be done multiple ways and should be when throughly testing your code. However, for this Assessment's output, we will use the following method: a. Print to the console the message, "Assessment 10 - Classes and Inheritance" followed by a blank line. b. Print "Section 3: Base Class Results After Adding" to the console followed by a blank line. c. Instantiate an object called gameOne, from the scoreKeeper class, passing "Canasta" as the game name to the constructor. d. Call the addName() method three times to add the players, "Larry", "Moe", and "Curly". e. Print a blank line to the console for ease of reading. f. Call the object's addScore() method three times. Once for Larry adding 20 points to his score. A second time for Moe adding 35 points to Curly's score. Then a third time for Curly, adding 45 points to Curly's score. g. Using the listAllScores() method, print a report of the players and their respective scores to the console. h. Call the object's subScore() method twice. Once for Moe subtracting 15 points from his score. The second time, subtract 5 points from Curly's score. i. Print "Section 3: Base Class Results After Subtracting" to the console followed by a blank line j. Using the listAllScores() method, print a report of the players and their respective scores to the console. k. Print two blank lines to the console./n2. Create a base class called scoreKeeper. a. Include a private property called gamePlayed to contain the name of the game being played. b. Add a private property which will allow for any number of players. A dictionary or dynamic array would be a good option. The container will hold the names and scores of the players. c. Include a new public method, addName(), to accept a player's name and insert it into the container. (Note: If the container you used does not have an add method to easily add a value, you will need to include code to determine the next available position.) d. e. f. g. h. Include a public method, subScore(), to update a player's score by passing it the player's name and the points to be subtracted. Return the updated score. Include a new public method, listAllScores(), to print the name of the game being played, the names of each player and their respective scores. j. Include two constructors. The first one is a default constructor. The second is a constructor method which will accept the name of the game and call the set Game(). i. Include a public method, getPlayerName(), to accept the number of the player and return the player's name. Include a public method setGame() to update the gamePlayed property by passing it a string containing the name of the game. Include a public method getGame() to retrieve the name of the game. Include a public method, addScore(), to update a player's score by passing it the player's name and the points to be added. Return the updated score. Section 2: 1. Enter the comment with the section title as described above. 2. Some games have additional information that must be monitored during play. Create a sub-class called baseball that inherits from the base class scoreKeeper. a. Add private integer properties for fouls, balls, strikes, and outs. b. Add a private decimal property to hold the inning number. Whole numbers will indicate the top of the inning and half numbers will indicate the bottom. e.g. 5.5 would indicate the bottom of the 5th c. Include a public method, advOuts(), to add 1 to the number of outs. If the number of outs reaches 3, reset balls, strikes, fouls and outs to 0 and add .5 to innings. d. Include a public method, getOuts(), to return the current number of outs. e. Include a public method, advStrikes(), to add 1 to the number of strikes. If the number of strikes reaches 3, call advOuts(). f. Include a public method, getStrikes(), to return the current number of strikes./nThis Competency Assessment assesses the following outcome(s): Course Outcome practiced in this assessment: IT232M5: Examine object-oriented programming concepts. Purpose The purpose of this assessment is to provide you with an opportunity to demonstrate knowledge of creating classes, instantiating objects from those classes, and expanding the functionality of a class through inheritance. Assessment Instructions In this scenario, your group has been tasked with creating a score keeping program for games. You have been assigned to create and test the classes necessary. You will create a single, console program with multiple sections. In it, you will create a base class and an inherited class. Then you will write code to instantiate objects from each class and test their functionality. Please keep in mind that with all the Assessments in this course, any given scenarios are hypothetical and intended solely to demonstrate specific skills. Challenge: Once you have created the following console program and tested it to make sure all of its specifications work, why not go back and try creating a GUI to use the derived class? (This challenge does not count as part of your assessment grade and is not required.) Assessment Requirements Note: If your language of choice is Web Development, you will need to complete the exercises in both PHP and JavaScript. Using the language in which you have chosen to focus: C#, Java, Web Development languages (PHP and JavaScript), please complete the following Assessment: The program for this Assessment will consist of four sections, each headed by the three-line comment below: //************* *** //**** Assessment 5 Section X //******* (where X stands for the portion of the Assessment to follow.) Section 1: ********* 1. Enter the comment with the section title as described above.

Fig: 1

Fig: 2

Fig: 3

Fig: 4

Fig: 5