[Solved] IT2650 Assignment12

$25

File Name: IT2650_Assignment12.zip
File Size: 178.98 KB

SKU: [Solved] IT2650 Assignment12 Category: Tag:
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 Circleclass Circle extends Shape { public Circle (double r) { area = 3.14 * r * r; } public void getArea () { System.out.println(Circles area = + area); };} // Class Square class Square extends Shape { public Square (double s) { area = s * s; } public void getArea () { System.out.println(Squares 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 doesnt 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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] IT2650 Assignment12[Solved] IT2650 Assignment12
$25