for my exams in Java in a couple of weeks i go trough any old exams i get my fingers on. But there is one task i can't get my head arround. I need a solution for this.
You should creat a abstract Class called Plant(just with Attributes for height and weight). There are three Sub Classes (Tomato, Bellpeper and Onions)
Then you need a Class called Greenhouse, in this Greenhouse is room for Excactly 30 Plants in total. It dosent matter what kind of Plants.
If you want to store more then 30 Plants then it should drop a Exception.
i know i need:
- a Final attribute for the 30 plants.
- Array.Add to get the Objects in my Array.
- and a Method that calculated 30 - the length of my Array List.
but i dont know how to use this. There a lot of Tutorials for stuff like this in the same class but not from another class.
I hope someone can help me.
Greetings from Germany