015-004-001

Point Card Array

Easy

Problem Description

In this problem, you will create a program that implements a Card base class with GoldCard and SilverCard subclasses, uses polymorphism to store different card types in a Card[] array based on input, iterates through them calling the polymorphic methods getType() and getPoints() on each card, and displays the result to standard output.

Read the number of cards n and each card type (G or S) from standard input. Create a Card base class with GoldCard and SilverCard subclasses. Store the corresponding card types in a Card[] array and iterate through them, calling polymorphic methods getType() and getPoints() on each.

Input format:

  • Line 1: number of cards n
  • Next n lines: card type for each card (G: GoldCard, S: SilverCard)

Output format:

  • For each card: [type]: [points] points on its own line

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
3
G
S
G
Expected Output:
Gold: 1000 points
Silver: 500 points
Gold: 1000 points
Normal case
Input:
2
G
G
Expected Output:
Gold: 1000 points
Gold: 1000 points

Your Solution

Current Mode: My Code
Card.java🔒
GoldCard.java🔒
SilverCard.java🔒
Main.java🔒
4/6 ファイル476B
class Card {
}
0 B / 5 MB

You have 10 free executions remaining