[SOLVED] IT2650 Assignment12

30.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Assignment_12-pre1ul.zip (710.7 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (1 vote)

I used the online compiler: https://www.jdoodle.com/online-java-compiler/

However, you can use any IDE as long as you submit code that I can compile and execute.

 

// Class Shape import java.awt.*;

 

abstract class Shape {    double area;    public abstract void getArea () ;

}

 

// Class Circle

class Circle extends Shape {

 

public Circle (double r) {       area = 3.14 * r * r;

 

}

 

public void getArea () {

 

System.out.println(“Circle’s area = ” + area);

 

};

}

 

// Class Square class Square extends Shape {

 

public Square (double s) {       area = s * s;

 

}

 

public void getArea () {

 

System.out.println(“Square’s area = ” + area);

 

};

}

 

public class Assignment11 {

 

public static void main(String[] args) {

 

      System.out.println (“Assignment 12 Written by Matt Weisfeld”);

 

Circle circle1 = new Circle(3);

Circle circle2 = new Circle(4);

 

Square square1 = new Square(2);

Square square2 = new Square(5);

 

Circle[] circleArray = new Circle[2];

Square[] squareArray = new Square[2];

 

circleArray[0] = circle1;        circleArray[1] = circle2;

 

squareArray[0] = square1;        squareArray[1] = square2;

 

for (int i = 0; i < circleArray.length; i++) {

 

circleArray[i].getArea(); squareArray[i].getArea();

 

}

 

}

}

 

 

Step 02 – Run the code (the output should look something like this)

 

Step 03 – Add the code

The code above iterates through the two separate arrays – circleArray and squareArray.

Your task is to create an array called shapeArray (that holds 4 shapes) and insert the 4 shapes created by the code below, circle1, circle2, square1, square2.

Now, I want you to create code that iterates through the shapeArray and processes any shape. In essence, the code doesn’t care which shape it is processing.

All that you need to turn in is your final version of A12. So upload that single file to Blackboard.

Step 04 – When you run the code you will get something like the following output

Step 05 – Submit the updated file to A 12.

 

Submit the file to Blackboard.

  • Assignment_12-pre1ul.zip