Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.*;
- interface In {
- public void print();
- }
- class Point {
- private double x;
- private double y;
- public Point() {
- this.x = 0.0;
- this.y = 0.0;
- }
- public Point(double x, double y) {
- this.x = x;
- this.y = y;
- }
- }
- abstract class Shape implements In {
- private enum Painter {
- BRUSH,
- BALLPEN
- }
- private enum Color {
- RED,
- GREEN,
- BLUE
- }
- }
- class Line extends Shape {
- private Point startP;
- private Point endP;
- public Line() {
- this.startP = new Point();
- this.endP = new Point();
- }
- public Line(Point startP, Point endP) {
- this.startP = startP;
- this.endP = endP;
- }
- @Override
- public void print() {
- System.out.println("Line");
- }
- }
- class Circle extends Shape {
- private Point tam;
- private double R;
- public Circle() {
- this.tam = new Point();
- this.R = 0.0;
- }
- public Circle(Point tam, double R) {
- this.tam = tam;
- this.R = R;
- }
- @Override
- public void print() {
- System.out.println("Circle");
- }
- }
- class Rectangle extends Shape {
- private Point diemTrenTrai;
- private Point diemDuoiPhai;
- public Rectangle() {
- this.diemTrenTrai = new Point();
- this.diemDuoiPhai = new Point();
- }
- public Rectangle(Point diemTrenTrai, Point diemDuoiPhai) {
- this.diemTrenTrai = diemTrenTrai;
- this.diemDuoiPhai = diemDuoiPhai;
- }
- @Override
- public void print() {
- System.out.println("Rectangle");
- }
- @Override
- public boolean equals(Object o) {
- if (o instanceof Rectangle) {
- return this == o && this.diemTrenTrai.equals(((Rectangle) o).diemTrenTrai)
- && this.diemDuoiPhai.equals(((Rectangle) o).diemDuoiPhai);
- } else {
- return false;
- }
- }
- }
- class Image implements In {
- private Line line;
- private Circle circle;
- private Rectangle rectangle;
- public Image() {
- this.line = new Line();
- this.circle = new Circle();
- this.rectangle = new Rectangle();
- }
- public Image(Line _line, Circle _circle, Rectangle _rectangle) {
- this.line = _line;
- this.circle = _circle;
- this.rectangle = _rectangle;
- }
- @Override
- public void print() {
- line.print();
- circle.print();
- rectangle.print();
- }
- }
- class Main {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement