Advertisement
Guest User

Denis M

a guest
Jul 31st, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1.  
  2. import java.awt.Color;
  3. import java.awt.Graphics;
  4. import java.awt.Graphics2D;
  5. import java.awt.geom.Rectangle2D;
  6.  
  7. /*
  8. * To change this license header, choose License Headers in Project Properties.
  9. * To change this template file, choose Tools | Templates
  10. * and open the template in the editor.
  11. */
  12.  
  13. /**
  14. *
  15. * @author dmamedov
  16. */
  17. public class Shapes {
  18. int xcords;
  19. int ycords;
  20.  
  21. public Shapes (int xcodrs, int ycords) {
  22. this.xcords = xcords;
  23. this.ycords = ycords;
  24.  
  25. }
  26. public int getX() {return xcords;}
  27.  
  28. public int getY() {return xcords;}
  29. }
  30.  
  31. class Cycle extends Shapes {
  32.  
  33. private int width;
  34. private int height;
  35.  
  36. public Cycle(int xcodrs, int ycords, int widthnew, int heightnew){
  37. super(xcodrs, ycords);
  38. setWight(widthnew);
  39. setHeight(heightnew);
  40. }
  41.  
  42. public void setWight(int widthnew) {
  43. width = widthnew;
  44. }
  45. public void setHeight(int heightnew){
  46. height = heightnew;
  47. }
  48. public void paintComponent(Graphics g) {
  49. Graphics2D g2 = (Graphics2D) g;
  50. g.setColor(Color.black);
  51. g.drawOval(xcords, ycords, width, height);
  52.  
  53. }
  54.  
  55.  
  56. }
  57. class Rectangle extends Shapes {
  58. private int width;
  59. private int height;
  60.  
  61. public Rectangle(int xcodrs, int ycords,int widthnew, int heightnew ) {
  62. super(xcodrs, ycords);
  63. setWight(widthnew);
  64. setHeight(heightnew);
  65.  
  66. }
  67. public void setWight(int widthnew) {
  68. width = widthnew;
  69. }
  70. public void setHeight(int heightnew){
  71. height = heightnew;
  72. }
  73.  
  74.  
  75. public void paintComponent(Graphics g) {
  76. Graphics2D g2 = (Graphics2D) g;
  77. g.setColor(Color.black);
  78. g.drawRect(xcords, ycords, width, height);
  79.  
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement