018-004-001

Object equals() Comparison

Easy

Problem Description

Create a PointCard class with cardNumber field and implement equals() method to compare cards by their card number rather than object identity.

Test Cases

※ Output examples follow programming industry standards

Input:
new PointCard("A001"); PointCard c2 = new PointCard("A001"); c1.equals(c2)
Expected Output:
true
Input:
new PointCard("A001"); PointCard c2 = new PointCard("B002"); c1.equals(c2)
Expected Output:
false
Input:
new PointCard("A001"); c1.equals("A001")
Expected Output:
false
Input:
new PointCard("A001"); c1.equals(null)
Expected Output:
false
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here

sc.close();
}
}
0 B / 5 MB

You have 9 free executions remaining