首页 > 代码库 > Java练习题4_3_2407林大锐格平台

Java练习题4_3_2407林大锐格平台

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();
	}
}

 

Java练习题4_3_2407林大锐格平台