fosterbl

RectangleRunner.java

Feb 14th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public class RectangleRunner{
  2.    public static void main(String[] args){
  3.       Rectangle def = new Rectangle();
  4.       System.out.println( "This is a default rectangle. I will call its toString by printing this object out" );
  5.       System.out.println( def );
  6.       System.out.println( "Now I will change the values of this default rectangle using mutators");
  7.       def.setLength(3);
  8.       def.setWidth(4);
  9.       System.out.println( def );
  10.       System.out.println("Here is the length alone using its accessor");
  11.       System.out.println( def.getLength() );
  12.       System.out.println("I could create another rectangle using just its specified constructor");
  13.       Rectangle r = new Rectangle(5, 12);
  14.       System.out.println( r );
  15.       System.out.println("Here is this rectangle's diagonal " + r.diagonal() );
  16.    }
  17. }
Add Comment
Please, Sign In to add comment