package org.jsoft.homework;
public class Chang extends Shape{
private int width;
private int length;
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
}
package org.jsoft.homework;
public class Circle extends Shape{
private int r;
public int getR() {
return r;
}
public void setR(int r) {
this.r = r;
}
}
package org.jsoft.homework;
public class Zheng extends Shape{
private int sideLength;
public int getSideLength() {
return sideLength;
}
public void setSideLength(int sideLength) {
this.sideLength = sideLength;
}
}
package org.jsoft.homework;
import java.util.Scanner;
public class Shape {
private int r;
private int width;
private int length;
private int sideLength;
public int getSideLength() {
return sideLength;
}
public void setSideLength(int sideLength) {
this.sideLength = sideLength;
}
public int getR() {
return r;
}
public void setR(int r) {
this.r = r;
}
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getLength() {
return length;
}
public void setLength(int length) {
this.length = length;
}
public Shape getShape(Shape c,Shape j,Shape z){
Scanner sc=new Scanner(System.in);
int i1=sc.nextInt();
if(i1==0){
return c;
}else if(i1==1){
return j;
}else if(i1==2){
return z;
}
return null;
}
}
package org.jsoft.homework;
import java.util.Scanner;
public class TX {
public static void main(String[] args) {
Shape c=new Circle();
c.setR(2);
Shape j=new Chang();
j.setLength(4);
j.setWidth(2);
Shape z=new Zheng();
z.setSideLength(2);
Shape s=new Shape();
s.getShape(c, j, z);
}
}