Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. System.out.println("Test 1 :");
  4. Rectangle rect = new Rectangle(12.5, 4.0);
  5. System.out.println(rect);
  6. System.out.println();
  7. System.out.println("Test 2: ");
  8. // the type of rect1 is ColoredRectangle
  9. // the object contained in rect1 is of type ColoredRectangle
  10. ColoredRectangle rect1 = new ColoredRectangle(12.5, 4.0, "red");
  11.  
  12. System.out.println(rect1);
  13. System.out.println();
  14. System.out.println("Test 3 :");
  15. // the type of rect2 is Rectangle
  16. // the object contained in rect2 is of type ColoredRectangle
  17. Rectangle rect2 = new ColoredRectangle(25.0/2, 8.0 / 2, newString("red"));
  18. System.out.println(rect2);
  19. System.out.println(rect1.equals(rect2)); // 1.
  20. System.out.println(rect2.equals(rect1)); // 2.
  21. System.out.println(rect1.equals(null)); // 3.
  22. System.out.println(rect.equals(rect1)); // 4.
  23. System.out.println(rect1.equals(rect)); // 5.
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement