Advertisement
Guest User

Untitled

a guest
Jan 24th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package figury;
  7.  
  8. import java.awt.Color;
  9. import java.awt.Graphics;
  10. import java.awt.Graphics2D;
  11.  
  12. /**
  13. *
  14. * @author asus
  15. */
  16. public class Kolo extends Punkt {
  17.  
  18. protected int R;
  19. protected Color pedzel;
  20.  
  21. public Kolo(int wspX, int wspY, int R_, Color color) {
  22. super(wspX, wspY, color);
  23. R = R_;
  24. pedzel = color;
  25. }
  26.  
  27. @Override
  28. public int getDl() {
  29. return R;
  30. }
  31.  
  32. @Override
  33. public int getSzerokosc() {
  34. return R;
  35. }
  36.  
  37. @Override
  38. public boolean lezy_na(int x, int y, Punkt p) {
  39. return Math.sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y)) <= R;
  40. }
  41.  
  42. @Override
  43. public int hashCode() {
  44. int hash = 7;
  45. hash = 97 * hash + this.R;
  46. return hash;
  47. }
  48.  
  49. @Override
  50. public boolean equals(Object obj) {
  51. if (this == obj) {
  52. return true;
  53. }
  54. if (obj == null) {
  55. return false;
  56. }
  57. if (getClass() != obj.getClass()) {
  58. return false;
  59. }
  60. final Kolo other = (Kolo) obj;
  61. if (this.R != other.R) {
  62. return false;
  63. }
  64. return this.compareTo(obj) == 0;
  65. }
  66.  
  67. @Override
  68. public String toString() {
  69. String s = super.toString();
  70. return "Kolo{" + "promien= " + R + '}' + " i dziedzicze od " + s;
  71. }
  72.  
  73. @Override
  74. public void rysuj(Graphics g) {
  75. Graphics2D g2D = (Graphics2D) g;
  76. g2D.setColor(pedzel);
  77. g2D.fillOval(x, y, R, R);
  78. }
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement