001package types.point3;
002import java.awt.Color;
003interface Point {
004        double getX();
005        double getY();
006}
007final class CartesianPoint implements Point {
008        
009        private final double x;
010        private final double y;
011        private final Color color;
012        public CartesianPoint(double x, double y, Color color) {
013                this.x = x;
014                this.y = y;
015                this.color = color;
016        }
017        public double getX() { return x; }
018        public double getY() { return y; }
019        public Color getColor() {
020                System.out.println("It's Cartesian!");
021                return color;
022        }
023        
024}
025final class PolarPoint implements Point {
026        
027        private final double theta;
028        private final double r;
029        private final Color color;
030        public PolarPoint(double theta, double r, Color color) {
031                this.theta = theta;
032                this.r = r;
033                this.color = color;
034        }
035        public double getX() { return r*Math.cos(theta); }
036        public double getY() { return r*Math.sin(theta); }
037        public Color getColor() {
038                System.out.println("It's Polar!");
039                return color;
040        }
041        
042}
043public class Main {
044        private Main() {}
045        public static void main(String[] args) {
046                CartesianPoint p1 = new CartesianPoint(0,0,Color.RED);
047                CartesianPoint q1 = new CartesianPoint(1,1,Color.BLUE);
048                PolarPoint r1 = new PolarPoint(0,0,Color.RED);
049
050                Point p2 = p1;
051                Point q2 = q1;
052                Point r2 = r1;
053        }
054}