How do you use subclassing to design simple class hierarchies that allow code to be reused for distinct subclasses? (250 own words)
what is subclass:
classes can be derived from other classes. The derived class is called a subclass.
The class from which it's derived is called the superclass.
The object oriented paradigm supports code reuse through inheritance. classes exist in a object oriented language in a class heirarchy.
A class can be declared as a subclass of another class,which is called the parent class.which is called as parent class or super class.
inheritance comes into two varieties:single inheritance and multiple inheritance.
in single inheritance the class hierarchy from a tree rooted in the most general class.
Single inheritance enables a derived class to inherit properties and behavior from a single parent class. It allows a derived class to inherit the properties and behavior of a base class, thus enabling code reusability as well as adding new features to the existing code.
in multiple inheritance : which allows class to be a subclass of one or more superclasses.
Multiple Inheritance is a feature of object oriented concept, where a class can inherit properties of more than one parent class. The problem occurs when there exist methods with same signature in both the super classes and subclass. On calling the method, the compiler cannot determine which class method to be called and even on calling which class method gets the priority.
if you have any doubts ask me.... thank you
How do you use subclassing to design simple class hierarchies that allow code to be reused...
There are design imperfections with this code. relating to encapsulation (in terms of the class), and something to do with how age is calculated being rigid (in terms of it only works for 2019, and will break next year). Improve the design of this code, and add a short comment or two up the top explaining what you've done and why. code: class Student: def __init__(self, firstName, lastName, birth_year): self.name = firstName + " " + lastName self.birth_year = birth_year...
Use Visual Studio for the following: Add an HourlyPlusCommissionEmployee class to the PayrollSystem app by subclassing an existing class. A HourlyPlusCommissionEmployee is a kind of CommissionEmployee with the following differences and specifications: HourlyPlusCommissionEmployee earns money based on 2 separate calculations: commissions are calculated by the CommissionEmployee base class hourly pay is calculated exactly the same as the HourlyEmployee class, but this is not inherited, it must be duplicated in the added class BasePlusCommissionEmployee inherits from CommissionEmployee and includes (duplicates) the...
How do you design a simple synchronous counter with an asynchronous reset? Please draw examples of: (a) a 2-bit counter with these specifications and (b) a 3-bit counter with these specifications
(The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...
Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make Chicken and Cow as subclasses of Dairy. The Sheep and Dairy classes implement the Edible interface. howToEat) and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML...
THIS IS IN THE JAVA SCRIPT CODE
ALSO PLEASE SEND ME THE CODE TYPED THANK YOU.
Program 1 Write an inheritance hierarchy of three-dimensional shapes. Make a top-level shape interface that has methods for getting information such as the volume and the surface area of a three-dimensional shape. Then make classes and subclasses that implement various shapes such as cube, cylinders and spheres. Place common behavior in superclasses whenever possible, and use abstract classes as appropriate. Add methods to the...
How do you determine the relationship between 2 variables? And how do you use simple linear regression to describe and test whether this relationship is significant?
Please use Java Question 3: Person and Customer classes: Design a class named Person with properties for holding a person's name, address, and telephone number. Next, design a class named Customer, which is derived from the Person class. The Customer class should have a property for a customer number and a Boolean property indicating whether wishes to be on a mailing list. Demonstrate an object of customer class in a simple GUI application. Write the code include appropriate input validation,...
How many fields does Access allow you to add to the Design grid?
JAVA Objective : • Learning how to write a simple class. • Learning how to use a prewritten class. • Understanding how object oriented design can aid program design by making it easier to incorporate independently designed pieces of code together into a single application. Instructions: • Create a project called Lab13 that contains three Java file called Book.java , Bookstore.java and TempleBookstore.java • I’ve provided a screenshot of how your project should look like. • Be sure to document...