QuestionQuestion

Discussion 1:
Select one of the following options:
Describe a real life scenario that can be modeled with inheritance. Then, explain why inheritance is a better model for your scenario than polymorphism.
Describe a real life scenario that can be modeled with polymorphism. Then, explain why polymorphism is a better model for your scenario than inheritance.

Discussion 2:
Create a class named CollegeCourse that includes 4 fields – the department name (e.g. “ENG”), the course number (e.g. 101), the number of credits (e.g. 3) and the course fee (e.g. “360”). Add getters and setters methods for each field. Add overloaded constructor, which accepts three parameters for the proper fields above, except for the fee field – the fee will be calculated as $120 per credit multiplied by the number of credits. Include a Display() method to display the course data.
Create a subclass of CollegeCourse class named LabCourse, which adds $50 to the course fee. Override the parent class Display() method to indicate that the course is a lab course and display all the subclass data.
Write an application driver UseCourse class with the main() method, which prompts a user for the course information (use Scanner class or JOptionPane). If a user enters a class in BIO or CHEM departments, create a LabClass object and enter other data to its fields. If a user enters any other department – create an object from the base CollegeCourse class that does not include the additional lab fee. Then – display the course data by calling the Display() method of the proper class.
Save the CollegeCourse class in the proper .java file, LabCourse class in the proper .java file and UserCourse driver class in the UseCourse.java file.
Zip all the files above and post as an attachment to your initial response. In the initial response itself, please provide comments and explanations of your solution with a proper UML diagram illustrating class hierarchy.

Assignment 1:
Create a Building class and two subclasses, House and School. The Building class contains fields for square footage and stories. The House class contains additional fields for the numbers of bedrooms and baths. The School class contains additional fields for the number of classrooms and grade level (e.g. elementary or junior high). All classes contain appropriate get and set methods and overloaded constructors allowing to accept and set the field data values.
Create an application driver class ShowBuildings, which creates the objects from the House and School classes, accepts the user’s input for the fields of proper object type and pass those to the object fields for storage.
Display the content of the every data field in the created object.
Compile, run, and check the results. Submit the following:
Four .java files (Building.java, House.java, School.java, ShowBuildings.java) and one .doc file with the screen shots of the running application.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

1. Discussion 1:
Describe a real life scenario that can be modeled with inheritance. Then, explain why inheritance is a better model for your scenario than polymorphism.
a. Firstly, we know that both of them extends existing class to make a subclass. The most different between inheritance and polymorphism is that we add new function to the sub class when we use inheritance model and we reuse the function of the super class to give it a new implementation when we use polymorphism model.
b. Secondly, the scenario
i. We want model many kind of vehicles
ii. We create a class of vehicle and its sub class
class vehicle{
int registration_number;
string owner ;
void sold(string new_owner);
………………….
}
class car extends vehicle {
int numberofdoor;
……………..
}
class truck extends vehicle {
int numberofaxles;
……………..
}...
$73.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats