import java.util.Scanner; class Rectangular { private static int x, y; private static int countP = 0; public Rectangular(int xx, int yy) { x=xx; y=yy; } public Rectangular(Rectangular p) { x=p.x; y=p.y; } public int getX() { return x; } public int getY() { return y; } public static void GetC() { countP++; System.out.println("Object id=" + countP+" X*Y = "+ (x*y)); } } public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); Rectangular A=new Rectangular(sc.nextInt(),sc.nextInt()); A.GetC(); Rectangular B=new Rectangular(A); B.GetC(); } }
时间: 2024-10-19 00:46:19