Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve it using java program. Assume having a club that provides two racing games: car racing and horse racing. 1. Implement the following classes

please solve it using java program.

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 class 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 getHorse1() that returns the first horse object in the array. Write this method. A method getHorse2() 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 The Class "Horse" has as attributes the age {int} and the name {String} and as methods: A constructor that initializes all attributes. The getter methods (getName( ) 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.

image text in transcribed

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_2

Step: 3

blur-text-image_3

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

SQL Instant Reference

Authors: Gruber, Martin Gruber

2nd Edition

0782125395, 9780782125399

More Books

Students also viewed these Databases questions

Question

8. Providing support during instruction.

Answered: 1 week ago