Skip to main content

Exercises 16.15 Exercises

1.

Complete the code by creating a Point p1 that represents (3, 4.5).

2.

The existing code will make a point p1 at (4, 3). Shift it so it is at (1, 1).

3.

The existing code will make a point p1. Make a point p2 that has x and y value that are 1 more than the values for p1.

4.

Add a definition for the getPerimeter function in Rectangle. Your code will be inside the class.

5.

Add a definition for the getArea function that is declared in Rectangle. Your code will be outside the class, so you need to use the scope resolution operator.

6.

Add a definitions for the 2-arg constructor You are defining it outside of the class. Check the comments for a hint on how it should behave.

7.

Add a definition for the scale function so the code passes the test. You are defining it outside of the class. Check the comment for tips on how it should behave.
You have attempted of activities on this page.