014-004-002

protected Modifier: Character Class

Easy

Problem Description

protected Modifier: Character class

In this problem, you will create a program that implements a Warrior class inheriting from Character, directly accesses protected fields from the child class, and calculates and displays Power (HP×2) along with character information to standard output.

Learning Objective: Access protected fields from child class for calculations

Define protected fields name and hp in the Character class, then implement the Warrior subclass to directly access these fields and output the character's name, HP, class name, and Power (HP×2).

Input

Line 1: Name (string)
Line 2: HP (integer)

Output

Name: [name]
HP: [HP]
Class: Warrior
Power: [HP*2]
```java

## Examples

### Example 1: Basic character
Input:
```java
Hero
100
```java
Output:
```java
Name: Hero
HP: 100
Class: Warrior
Power: 200
```java

### Example 2: Different character
Input:
```java
Knight
150
```java
Output:
```java
Name: Knight
HP: 150
Class: Warrior
Power: 300
```java

### Example 3: Boundary (minimum HP)
Input:
```java
A
1
```java
Output:
```java
Name: A
HP: 1
Class: Warrior
Power: 2

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
Mage
80
Expected Output:
Name: Mage
HP: 80
Class: Warrior
Power: 160
Normal case
Input:
Dragon
200
Expected Output:
Name: Dragon
HP: 200
Class: Warrior
Power: 400

Your Solution

Current Mode: My Code
Character.java🔒
Warrior.java🔒
Solution.java🔒
3/6 ファイル171B
public class Character {
}
0 B / 5 MB

You have 10 free executions remaining