Use BlueJ and the editor to find out the answers:
- What is the name of the Triangle class?
Triangle
- Give the Java code to create two Triangle objects named t1 and t2.
Triangle t1 = new Triangle();
Triangle t2 = new Triangle();
- How many fields are there in a Triangle object?
6
- What is the default color of a Triangle?
"green"
- How many methods are there in a Triangle object?
12
- Give the one line of Java code to:
- use the erase method on t1 Triangle object.
t1.erase();
is the obvious answer but... because erase() is private:
private void erase()
cannot use outside the Triangle class definition nor does erase() appear on the list of Triangle methods in BlueJ.
- move t2 Triangle object vertically a distance of 20.
t2.moveVertical(20);
- change the color of t2 Triangle object.
t2.changeColor("red");