017-002-001

Inheritance and Control Flow: Password Validation System

Easy

Problem Description

inheritance and Control Flow: Password Validation System

In this problem, you will create a program that implements a StrictValidator class inheriting from Validator, overrides the validate method to apply different password length criteria, and displays the validation result to standard output.

Learning Objective: Understand how to implement different validation rules with inheritance and method overriding

Create basic password validator class and strict validator class that inherits from it. Learn object-oriented flexibility by applying different validation criteria with same validate method depending on class.

Understanding with Concrete Examples

Example 1: Pass Strict Criteria (12 characters)

  • Input: 12
  • Class Used: StrictValidator (10+ character standard)
  • Validation Processing: 12 >= 10 → true
  • Judgment Result: "Valid"
  • Output: "Password Validation:" "Length: 12characters" "Result: Valid"

Example 2: Fail Strict Criteria (8 characters)

  • Input: 8
  • Class Used: StrictValidator (10+ character standard)
  • Validation Processing: 8 >= 10 → false
  • Judgment Result: "Invalid" (Would pass with basic class but fails with strict class)
  • Output: "Password Validation:" "Length: 8characters" "Result: Invalid"

Example 3: Boundary Value (exactly 10 characters)

  • Input: 10
  • Class Used: StrictValidator (10+ character standard)
  • Validation Processing: 10 >= 10 → true (boundary value included)
  • Judgment Result: "Valid"
  • Output: "Password Validation:" "Length: 10characters" "Result: Valid"

Input

Line 1: Password length (integer, 1-50)

Output

Password Validation:
Length: [length]characters
Result: [result]

Validation criteria:

  • Basic Class (Validator): Pass with 6+ characters
  • Strict Class (StrictValidator): Pass with 10+ characters (override)

Key Point: Using inheritance enables achieving different behavior with same method name. This is called polymorphism.

Test Cases

※ Output examples follow programming industry standards

Input:
12
Expected Output:
Password Validation:
Length: 12characters
Result: Valid
Input:
8
Expected Output:
Password Validation:
Length: 8characters
Result: Invalid
Input:
10
Expected Output:
Password Validation:
Length: 10characters
Result: Valid
Input:
5
Expected Output:
Password Validation:
Length: 5characters
Result: Invalid
❌ Some tests failed
❌ エラー発生

Your Solution

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

You have 6 free executions remaining