Lab2 - COE 618 Lab2 Part A Interface In the Netbeans program click on Project > New Project and save it as\"Exercise1 on your lab2 directory Define an

Lab2 - COE 618 Lab2 Part A Interface In the Netbeans...

This preview shows page 1 - 2 out of 2 pages.

COE 618: Lab2 Part A: Interface In the Netbeans program, click on Project > New Project and save it as "Exercise1" on your lab2 directory.Define an interface Shapewith methods double area(); double perimeter(); void scale(double factor); The last procedure scales the shape in each direction by the given factor. For example, scale(2) makes a shape twice as wide and twice as high, while scale(0.5) halves its dimensions. Define some classes that implement this interface: Rectanglewith a constructor taking the width and height of the rectangle are arguments. Circlewith a constructor taking the radius as argument. You will need the constant Math.PI. Define a class ArrayofShapescontaining an array of shapes and a count of how many are currently stored (initially 0): private Shape[] shape; private int shapeCount; With arrays, we must choose a size when the array is created. In this case, just choose a size and assume that the user won't add more shapes than that. You can add a shape like so: public void addShape(Shape s) {
Image of page 1
Image of page 2

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture