Find the error(s) in the following code. The following method should create a new Shape object with numberSides sides. Assume the Shape class is from Exercise 18.14.

```
1 private void manipulateShape( int numberSides )
2 {
3 Shape shape = new Shape( 3 );
4
5 shape.sides = numberSides;
6 }
```

The instance variable sides of class Shape is private so its value cannot be set directly as line 5 attempts to do. Line 5 should be changed to shape.setSides( number- Sides ); to properly set the value of sides.
```
1 private void manipulateShape( int numberSides )
2 {
3 Shape shape = new Shape( 3 );
4
5 shape.setSides( numberSides );
6 }
```

Computer Science & Information Technology

You might also like to view...

________ is a free, real-time blogging system in which you send and read short messages of up to 140 characters.

a. Facebook b. LinkedIn c. MySpace d. Twitter

Computer Science & Information Technology

The C++ _____ allows you to define an object type in terms of its components and its behavior.

a. constructor function b. list creation facility c. scope resolution operator d. class definition facility

Computer Science & Information Technology