014-002-003

Copy Constructor: Coordinate Class

Easy

Problem Description

Copy constructor: Coordinate class

In this problem, you will create a program that implements a copy constructor in the Point class to duplicate an existing object into a new one, then displays the coordinates of both the original and copied objects to standard output.

Learning Objective: Understand how to clone objects using copy constructor

Implement a copy constructor in Point class to create a new object from an existing one.

Input

Line 1: x coordinate (integer)
Line 2: y coordinate (integer)

Output

Original: ([x], [y])
Copy: ([x], [y])
Same object: false

Test Cases

※ Output examples follow programming industry standards

Input:
3
4
Expected Output:
Original: (3, 4)
Copy: (3, 4)
Same object: false
Input:
0
0
Expected Output:
Original: (0, 0)
Copy: (0, 0)
Same object: false
Input:
-5
10
Expected Output:
Original: (-5, 10)
Copy: (-5, 10)
Same object: false
Input:
3
4
Expected Output:
Original: (3, 4)
Copy: (3, 4)
Same object: false
❌ Some tests failed
❌ エラー発生

Your Solution

Current Mode: My Code
Point.java🔒
Solution.java🔒
2/6 ファイル94B
⚠️警告
  • No main method found
import java.util.Scanner;

class Point {
}
0 B / 5 MB

You have 6 free executions remaining