Question: Q 1 : About Polymorphism 5 P t s Consider the following inheritance hierarchy. A class 'Computer' that has: One instance variable name of type

Q1: About Polymorphism
5Pts
Consider the following inheritance hierarchy.
A class 'Computer' that has:
One instance variable "name" of type String.
One instance variable "downloadSpeed" of type double giving download speed of the
network in MB/s.(megabytes/second)
A subclass 'PersonalComputer' that:
has one additional private instance variable "connectionTime" of type double
indicating the number of seconds the computer was connected.
one method "totalMegaBytesDownloaded ()" calculating the Total megabytes
downloaded by mutiplying the downloadSpeed by connectionTime.
A Desktop class which is a subclass of PersonalComputer that :
has an additional variable "goodCondition" of type boolean.
overrides totalMegaBytesDownloaded () method as follows:
if goodCondition = true, the total MB downloaded are increased by 20%
if goodCondition false, the total MB downloaded are reduced by 20%
A Laptop class which is a subclass of PersonalComputer that:
as an additional variable "wirelessAva1lable" of type boolean.
overrides totalMegaBytesDownloaded() method as follows:
if wirelessAvailable = true, the total MB downloaded is 3000MB.
if wirelessAvailable = false, the total MB downloaded is zero.
Page 1 of 5
Provide suitable constructor(s), accessor/mutator methods and a tostring() method for
all the classes. Write an application class that generates an array of type Computer of 6
objects from either a Desktop or a Laptop. For example
Computer e1= new LapTop ("Toshiba",56.5,100, true);
Print the following information about your array:
the total number of desktops in your collection
the total number of laptops in your collection
the total MB downloaded by all desktops in your collection
the total MB downloaded by all laptops in your collection.
the average MB downloaded by all desktops in your collection.
the average MB downloaded by all laptops in your collection.
the number of desktops in good condition.
the number of laptops with wireless not available.
 Q1: About Polymorphism 5Pts Consider the following inheritance hierarchy. A class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!