This site requires JavaScript, please enable it in your browser!
Greenfoot back
Zweeg
Zweeg wrote ...

2019/3/5

How to access variables of subclass while calling the super

Zweeg Zweeg

2019/3/5

#
In the cash-register class, I need to print the names and prices of specific food classes which are all extensions of the FoodItem abstract super class. However, I need to call the FoodItem class when printing because I have an arrayList of FoodItem objects. How would I call the subclass's own variables and methods through the FoodItem class?
danpost danpost

2019/3/6

#
I cannot be sure without actually seeing the FoodItem class codes, but I have a feeling the array is not in the right class.
You need to login to post a reply.