014-007-002

final Method: Game Rules

Easy

Problem Description

final method: Game Rules

In this problem, you will create a program that defines methods with the final modifier in a GameBase class, implements a ChessGame class that inherits from it, and displays game rules and setup information to standard output.

Learning Objective: Define methods that cannot be overridden using final keyword

Create GameBase class representing game base and ChessGame class inheriting from it. Final methods guarantee common rules that cannot be changed in child classes.

Input

4 lines of input:

  • Line 1: Game name (e.g., Chess)
  • Line 2: Maximum number of players (integer)
  • Line 3: Turn time limit in seconds (integer)
  • Line 4: Game-specific setup description

Output

===== {gameName} Game =====
[GAME RULE] Max players: {maxPlayers}
[GAME RULE] Turn time limit: {turnTimeLimit} seconds
{gameName}-specific setup: {setupDescription}
=====================

Examples

Example 1: Chess Game

Input:

Chess
2
30
Setting up pieces

Output:

===== Chess Game =====
[GAME RULE] Max players: 2
[GAME RULE] Turn time limit: 30 seconds
Chess-specific setup: Setting up pieces
=====================

Example 2: Shogi Game

Input:

Shogi
2
60
Placing pieces on board

Output:

===== Shogi Game =====
[GAME RULE] Max players: 2
[GAME RULE] Turn time limit: 60 seconds
Shogi-specific setup: Placing pieces on board
=====================

Characteristics of final Methods

  • showMaxPlayers() is final so cannot be overridden in child classes
  • showTurnTimeLimit() is also final so cannot be changed
  • setupGame() is normal method so can be overridden

Test Cases

※ Output examples follow programming industry standards

Normal case
Input:
Othello
2
45
Placing discs on board
Expected Output:
===== Othello Game =====
[GAME RULE] Max players: 2
[GAME RULE] Turn time limit: 45 seconds
Othello-specific setup: Placing discs on board
=====================
Normal case
Input:
Poker
4
90
Dealing cards to players
Expected Output:
===== Poker Game =====
[GAME RULE] Max players: 4
[GAME RULE] Turn time limit: 90 seconds
Poker-specific setup: Dealing cards to players
=====================

Your Solution

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

You have 10 free executions remaining