ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 25 Apr 2017 My Price 9.00

Inheritance 1: Vehicle

Inheritance 1: Vehicle: A Vehicle class has been pre-coded in VPL. Within this class there are attributes, an integer noOfDoors representing the number of doors on a vehicle and a String brand representing the car’s brand. There is a Default and General Constructor along with relevant Getter and Setter Methods. This will act as a Parent Class from which you will inherit from with Car and SUV classes. Some methods and constructors are pre-coded for you and do not need to be changed. You should read through Vehicle.java and the pre-coded sections of each other class. a) In the car class: Make the Car class allow inheritance from Vehicle using a keyword. Create a Boolean attribute in Car called sportsModel that is true if the car is a sports model otherwise false. Write a default constructor for Car which should use the keyword super to invoke Vehicles constructor and sets sportsModel to false. Look at Vehicles General Constructor to see what the parameters are for correct use. A second constructor with an integer parameter, a String parameter and a boolean parameter. These parameters invoke Vehicles General Constructor and set sportsModel to the Boolean parameter. b) In the SUV class: Make the SUV class allow inheritance from Vehicle using a keyword. Write a default constructor for SUV that takes in an integer, and 2 Strings as parameters. wheelDrive should equal the 2nd String. wheelDrive represents whether the drive of SUV is “rear”, “front” or “4”. The other two parameters will be used for Vehicle’s constructor. Create getter and setter methods for wheelDrive with the signature getDrive() and setDrive(<…>). c) Create a tester class Tester which is a simple program with only a main method. Create a SUV object called suv1 using it’s default constructor. Create another SUV object using the general constructor, called suv2, with the values 2 for number of doors, “Nissan” for brand and “4” to represent 4-wheel-drive. Create a Car object called car1 with the values 3, “Ford” and true (to represent sports model). Use the relevant setter method to set suv1’s brand to “BMW”. Set the drive to “rear” and set noOfDoors to 5. Use Vehicle’s printDetails() method to print out suv1’s details and use getDrive() and a print statement to print suv1’s wheelDrive. See sample output. Set car1’s noOfDoors to 5. Use printDetails() on car1. Use a print statement and isSportsModel() to show whether car1 is a sportsModel. See sample output. Note: Notice how you are able to use Vehicle’s constructors as part of your more specific Car and SUV constructors. You are able to use Vehicle’s methods with the Car and SUV objects you created. Notice with the print statements in Vehicle’s constructors whether the general or default constructor is being invoked. Sample output: Default Constructor of the Super class called General Constructor of Vehicle called General Constructor of Vehicle called 5 BMW rear 5 Ford false

Attachments:

Answers

(11)
Status NEW Posted 25 Apr 2017 06:04 AM My Price 9.00

-----------

Attachments

file 1493103762-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)