Sie sind auf Seite 1von 2

 BRENNAN FULLEN

 OLEG SHCTURMAY

3.10 - An illegal value returns 0. A better way would be to format the if-statement to return an
error and not carry out the method unless the value wasn’t illegal.

3.11 - 0 would become an illegal value, even if logically you wanted 0 to be a valid value for the
replacement value.

3.12 - It would make it so that only one or the other would need to be true.

3.13 - 2 and 5.

3.14 - !(a && b) || (a && b)

3.15 - (a && ! b) || ( ! a && b)

3.16 - ! (!a || !b)

Modulo Operator:
3.20 - The modulo operator returns the remainder value.
3.21 - 8%3 is 2
3.22 - If the first number is negative, it returns a negative value. If the second value is negative,
it returns a positive value.
3.23 - The results could be either 0,1,2,3, or 4
3.24 - The results could either be 0,1,2,3,4,5,6,7,8, or 9
3.25 - By putting the limit on the right side of the modulo operator, any value that is less than
limit will return itself. So by comparing the value to limit with mod, the system can rollover when
the two values are equal.
3.26 -
public void increment(){
value=value+1;
if(value==limit){
value=0;
}
}

Creating Objects
3.30
private Rectangle window
window = new Rectangle(2,2);

3.31
This other constructor will create two NumberDisplay objects having 24 as an hour and 60 as
minutes their rollover limits so it will call setTime method, and that will call the NumberDisplay
setValue methods to change its value.
3.32
Because setTime is already doing it, so pretty much all constructors except steTime are the
same

Different Types of Method Calls


3.33 - p1.print(Naamloos, false);
p1.getStatus(5)
3.34 - circle, square, triangle, person, canvas, picture
3.35 - roof.changeSize(60, 180);
roof.moveHorizontal(20);
roof.moveVertical(-60);
roof.makeVisible();
3.36 - No
3.37public void draw()
{
wall = new Square();
wall.moveHorizontal(-140);
wall.moveVertical(20);
wall.changeSize(120);
wall.makeVisible();

window = new Square();


window.moveHorizontal(-120);
window.moveVertical(40);
window.changeSize(40);
window.makeVisible();

roof = new Triangle();


roof.changeSize(60, 180);
roof.moveHorizontal(20);
roof.moveVertical(-60);
roof.makeVisible();

sun = new Circle();


sun.moveHorizontal(100);
sun.moveVertical(-40);
sun.changeSize(80);
sun.makeVisible();

setColor();
}

Das könnte Ihnen auch gefallen