Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How will you program with java puter Scie New Tab room google.com/u/0/e/MTO NDgxODRa ttled documentM Intemships-Northr Race Horse Inheritance Inheritance -Rules to Remember 1. A

image text in transcribed

image text in transcribed

How will you program with java

puter Scie New Tab room google.com/u/0/e/MTO NDgxODRa ttled documentM Intemships-Northr Race Horse Inheritance Inheritance -Rules to Remember 1. A subclass can add new private instance variables. 2. A subclass can add new public or private methods. 3. A subclass can override (redefine) inherited methods. 4. A subclass must define its own constructors 5. A subclass cannot access the private members of its superclass Description A Horse class is defined with the following attributes and behaviors: Attributes (instance variables) . name the name of the horse . owner the owner of the horse . value how much the horse is worth Behaviors (methods) toString returns a string representation of the values stored in a horse object's instance variabies. Define a RaceHorse class with all of the attributes of the Horse class but with an additional attribute for the number of races a horse has won. Since a race horse is-a a type of horse this relationship can be represented Horse Race Horse Source Code Open and copy the foliowing workspace to your home directory Horse fications Make the following additions and modifications to the Racetorse class: 1. A subclass can add new private instance variables . Add an instance variable of type int named numRacesWon 2. A subclass can add new public or private methods 3 You Have A 4: B AP Computer Scie x New Tab tps/ dlassroom google.com/u//c/MTOSOTYINDgxoDRa s Untified document Internships Ne Source Code Open and copy the following workspace to your home directory Horse Make the following additions and modifications to the RaceHorse class 1. A subclass can add new private instance variables . Add an instance variable of type int named numRacesWon 2. A subclass can add new public or private methods. Add an accessor method named getRacesWon . . Add a mutator method named winRace 3. A subclass can override (redefine) inherited methods. .Override the toString method 4. A subclass must define its own constructors Add a default constructor Add a second constructor which includes 4 parameters to initialize the instanoe variables owner, age, value, and numRacesWon . 5. A subclass cannot access the private members of its superclass. wner John Wayne alue S250000.0 Races won- 2 wner Jimmy Stewart ge4 alue $325000.0 aces won 8

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

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

7 How should HRM practitioners approach conflict in the workplace?

Answered: 1 week ago