Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. # File: class-inheritance-2.rb
  2. #
  3. $LOAD_PATH << '.'
  4.  
  5. require 'point'
  6. require 'circle'
  7. require 'square'
  8. require 'triangle'
  9. require 'canvas'
  10.  
  11. canvas = Canvas.new(width: 300, height: 300)
  12.  
  13. # Add a circle to the canvas
  14. #
  15. circle = Circle.new(radius: 1.5, center: Point.new(10, 20))
  16. canvas.add(circle)
  17.  
  18. # Add a square to the canvas
  19. #
  20. square = Square.new(top_left: Point.new(30, 100), bottom_right: Point.new(50, 80))
  21. canvas.add(square)
  22.  
  23. # Add a triangle to the canvas
  24. #
  25. triangle = Triangle.new(first: Point.new(20, 30), second: Point.new(50, 10), third: Point.new(10, 5))
  26. canvas.add(triangle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement