Darano

Untitled

Oct 14th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.event.ActionEvent;
  4.  
  5. import javax.swing.JComboBox;
  6.  
  7. abstract class Shape {
  8.     abstract void draw(Graphics g);
  9.  
  10.     int x, y, diameter;
  11.     Color color = Color.PINK;
  12.  
  13.     public Shape(int x, int y, int diameter) {
  14.         this.x = x;
  15.         this.y = y;
  16.         this.diameter = diameter;
  17.     }
  18.  
  19.  
  20.     public void colorShape(Color color) {
  21.         this.color = color;
  22.     }
  23.  
  24.     void moveShape(int x2, int y2) {
  25.         x = x + x2;
  26.         y = y + y2;
  27.     }
  28.  
  29.     boolean checkForPoint(int xcoord, int ycoord) {
  30.         if (xcoord >= x && xcoord < x + diameter && ycoord >= y && ycoord < y + diameter)
  31.             return true;
  32.         else
  33.             return false;
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment