Matt Wilde wrote:how do I count the amount of Appliances that are added.
Matt Wilde wrote:Thank you so much that helped a lot!
my abstract method ElectronicDevice has a method getCurrentWattsPerHour().
I am trying to run that method from SurgeProtector by using
ElectronicDevice ED = new ElectronicDevice(); but i am getting an error "Cannot instantiate the type ElectronicDevice"
Matt Wilde wrote:Well thats the thing, I want to use the SurgeProtector's method to retrieve "getCurrentUsagePerHour()"
Matt Wilde wrote:what would you do if your Child class was also abstract?
Matt Wilde wrote:
Must I create new Objects in SurgeProtector for each of the children and run their getCurrentWatts method and add all those to get the total watts?
such as:
ElectronicDevice c = new CellPhone(wattsUsedPerHour,hoursUntilFullCharge);
double celluse = (double) c.getCurrentUsagePerSecond();
Appliance f = new Refrigerator(wattsUsedPerHour);
double fridgeuse = (double) r.getCurrentUsagePerSecond();
Appliance t = new TV(wattsUsedPerHour);
double tvuse = (double) t.getCurrentUsagePerSecond();
usage = celluse+tvuse+fridgeuse;
If you a pressed for time you need not respond you have done plenty and I am so grateful!
pie. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|