/** Inheritance demo. @author Jed Yang, 2017-04-03 */ import java.util.Scanner; public class Geometry { public static void main(String[] args) { Scanner kb = new Scanner(System.in); System.out.print("(r)ectangle or (c)ircle? "); String choice = kb.next(); Shape shape; if (choice.equals("r")) { shape = new Rectangle(); } else { shape = new Circle(); } // shape = new Shape(); System.out.println(shape); System.out.println("area = " + shape.getArea()); System.out.println("perimeter = " + shape.getPerimeter()); } }