I am using inheritance in a pretty standard exercise here.
I have a Card class and then a few classes that extend the Card class of different Card Types.
I however have a different type of class that still extends my Card class but is dealing with a LinkedList.
I have all of this accomplished, however in the exercise, there is a step that states "Have a main() method populate a Billfold object with Card objects, and then call
printCards()."
Here is the BillFold class.
import java.util.*; public class Billfold extends Card { LinkedList<Card> cards; Card firstCard; Billfold billf; public static void main(String[] args) { billf = new Billfold(); printCards(); } public Billfold() { cards = new LinkedList<Card>(); } public void addCard(Card newCard) { if(firstCard == null) firstCard = newCard; else cards.add(newCard); } public void printCards() { for(int i = 0; i < cards.size(); i++) { if(cards.get(i) != null) { super.print(); } } } }
And then here is the original Card class BillFold is extending
import java.util.*; import java.io.*; public class Card { private String name; private Card nextCard; public Card() { name = ""; } public Card(String n) { name = n; } public Card getNext() { return nextCard; } public boolean isExpired() { return false; } public void print() { System.out.println("Card holder: " + name); } public void setNext(Card c) { nextCard = c; } }
So my question is: What does it mean to populate a Billfold object with Card objects in my Billfold Class?
*Don't be confused by my inheritance info, this question is not about inheritance.
Thanks in advance.