Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CardContainer {
- List<Card> cards;
- public static void main(String argv[]) {
- CardContainer cardContainer = new CardContainer();
- cardContainer.addCard(new CardWithActions());
- cardContainer.addCard(new CardWithBonus());
- // I need to do something like
- String actionReward = cardContainer.getCard(0).getActionReward();
- }
- public CardContainer() {
- cards = new ArrayList<>();
- }
- public void addCard(Card card) {
- cards.add(card);
- }
- public Card getCard(int position) {
- return cards.get(position);
- }
- }
- public abstract class Card {
- protected String cardName;
- protected List<String> cost;
- protected String effect;
- public Card() {
- }
- public Card(String cardName, List<String> cost, String effect) {
- this.cardName = cardName;
- this.cost = cost;
- this.effect = effect;
- }
- public String getCardName() {
- return cardName;
- }
- public void setCardName(String cardName) {
- this.cardName = cardName;
- }
- public List<String> getCost() {
- return cost;
- }
- public void setCost(List<String> cost) {
- this.cost = cost;
- }
- public String getEffect() {
- return effect;
- }
- public void setEffect(String effect) {
- this.effect = effect;
- }
- }
- public class CardWithActions extends Card {
- private String action;
- private String actionReward;
- private String actionCost;
- public CardWithActions() {
- super();
- }
- public CardWithActions(String cardName, List<String> cost, String effect,
- String action, String actionReward, String actionCost) {
- super(cardName, cost, effect);
- this.action = action;
- this.actionReward = actionReward;
- this.actionCost = actionCost;
- }
- public String getAction() {
- return action;
- }
- public void setAction(String action) {
- this.action = action;
- }
- public String getActionReward() {
- return actionReward;
- }
- public void setActionReward(String actionReward) {
- this.actionReward = actionReward;
- }
- public String getActionCost() {
- return actionCost;
- }
- public void setActionCost(String actionCost) {
- this.actionCost = actionCost;
- }
- }
- public class CardWithBonus extends Card{
- private String bonusType;
- private String bonusDescription;
- public CardWithBonus() {
- }
- public CardWithBonus(String cardName, List<String> cost, String effect,
- String bonusType, String bonusDescription) {
- super(cardName, cost, effect);
- this.bonusType = bonusType;
- this.bonusDescription = bonusDescription;
- }
- public String getBonusType() {
- return bonusType;
- }
- public void setBonusType(String bonusType) {
- this.bonusType = bonusType;
- }
- public String getBonusDescription() {
- return bonusDescription;
- }
- public void setBonusDescription(String bonusDescription) {
- this.bonusDescription = bonusDescription;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement