CMPE 261 - Lab worksheet - Week 2

Problem 1

  1. Write a simple class named Point to represent a point in two dimensional coordinate system. Make sure it has a constructor.

  2. Add a method to compute distance of a point to another point. You may use Math.sqrt(x) method to compute square-root \(\sqrt{x}\) when finding distance, and Math.pow(x,2) to compute square (or other powers) of a number.

  3. Add a Tester class and test assertions.

Problem 2

Write a class to represent a book. Its constructor must accept the title of the book, and an array of names of its authors.

Hint: an array value is expressed as follows:

        int[] arr={1,2,3};
        String[] names={"abc","def"};