Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.geom.Rectangle2D;
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author dmamedov
- */
- public class Shapes {
- int xcords;
- int ycords;
- public Shapes (int xcodrs, int ycords) {
- this.xcords = xcords;
- this.ycords = ycords;
- }
- public int getX() {return xcords;}
- public int getY() {return xcords;}
- }
- class Cycle extends Shapes {
- private int width;
- private int height;
- public Cycle(int xcodrs, int ycords, int widthnew, int heightnew){
- super(xcodrs, ycords);
- setWight(widthnew);
- setHeight(heightnew);
- }
- public void setWight(int widthnew) {
- width = widthnew;
- }
- public void setHeight(int heightnew){
- height = heightnew;
- }
- public void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g.setColor(Color.black);
- g.drawOval(xcords, ycords, width, height);
- }
- }
- class Rectangle extends Shapes {
- private int width;
- private int height;
- public Rectangle(int xcodrs, int ycords,int widthnew, int heightnew ) {
- super(xcodrs, ycords);
- setWight(widthnew);
- setHeight(heightnew);
- }
- public void setWight(int widthnew) {
- width = widthnew;
- }
- public void setHeight(int heightnew){
- height = heightnew;
- }
- public void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- g.setColor(Color.black);
- g.drawRect(xcords, ycords, width, height);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement