Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

solve this question using java Assume having a club that provides two racing games: car racing and horse racing. 1. Implement the following classes as

image text in transcribed

solve this question using java

Assume having a club that provides two racing games: car racing and horse racing. 1. Implement the following classes as shown below: RacingGame class is characterized by two String attributes team1 and team2. This class has as methods: - A constructor that initializes the attributes. - A toString method that returns the information in the form TeamName1 vs. TeamName2. getter/setter methods. Do not implement these methods. CarRace closs inherits from RacingGame. It has four String attributes the type (e.g. Honda) and the year (e.g. 1998) of the first team and those of the second team. This class has as methods: A constructor that initializes all attributes. - A toString method that returns the information in the following form. TeamName1 vs. TeamName2 - Honda 1998 vs. BMW 1997 - getter/setter methods. Do not implement these methods. HorseRace class inherits from the class RacingGame. It has as an attribute an array of 2 horses and as methods: - A constructor that initializes all attributes. - A method getHorse10) that returns the first horse object in the array. Write this method. A method getHorse20 that returns the second horse object in the array. Write this method. - A toString method that returns the information of the two horses in the following forms. TeamName1 vs. TeamName - horseName1 Age1 vs. horseName2 Age2 Ihe Class "Horse" has as attributes the age { int } and the name { String } and as methods: A constructor that initializes all attributes. - The getter methods (get)lame(L) and getAge() ). Write the two get methods 2. Create an application as follows: a) Create an array, called games, of RacingGame objects with 10 objects. b) The user should enter the information of all the 10 objects. c) Write code to display the information of all racing games. d) Write code to count the number of HorseRace games

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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