Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * 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.
- */
- package figury;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- /**
- *
- * @author asus
- */
- public class Kolo extends Punkt {
- protected int R;
- protected Color pedzel;
- public Kolo(int wspX, int wspY, int R_, Color color) {
- super(wspX, wspY, color);
- R = R_;
- pedzel = color;
- }
- @Override
- public int getDl() {
- return R;
- }
- @Override
- public int getSzerokosc() {
- return R;
- }
- @Override
- public boolean lezy_na(int x, int y, Punkt p) {
- return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y)) <= R;
- }
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 97 * hash + this.R;
- return hash;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Kolo other = (Kolo) obj;
- if (this.R != other.R) {
- return false;
- }
- return this.compareTo(obj) == 0;
- }
- @Override
- public String toString() {
- String s = super.toString();
- return "Kolo{" + "promien= " + R + '}' + " i dziedzicze od " + s;
- }
- @Override
- public void rysuj(Graphics g) {
- Graphics2D g2D = (Graphics2D) g;
- g2D.setColor(pedzel);
- g2D.fillOval(x, y, R, R);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement