SOLUTION: shape s[] new shape[6] s[0]=new shape("red"); s[1]=new shape("blue"); s[2]=new Rectangle(1,2,"yellow"); s[3]=new Rectangle(10,20,"red"); s[4]=new Box(2,3,4,"blue"

Algebra ->  Test -> SOLUTION: shape s[] new shape[6] s[0]=new shape("red"); s[1]=new shape("blue"); s[2]=new Rectangle(1,2,"yellow"); s[3]=new Rectangle(10,20,"red"); s[4]=new Box(2,3,4,"blue"      Log On


   



Question 1028888: shape s[] new shape[6]
s[0]=new shape("red");
s[1]=new shape("blue");
s[2]=new Rectangle(1,2,"yellow");
s[3]=new Rectangle(10,20,"red");
s[4]=new Box(2,3,4,"blue");
s[5]=new Box(20,30,40,"black");

for (int i=0; i {if (s[i] instance of Box)
System.out.print((Box)s[i].volume());
if(s[i] instance of Rectangle&&!(s[i] instance of Box)
System.out.print((Rectangle)s[i].area());
if(s[i] instance of shape&&!(s[i] instance of Box)&&!
(s[i] instance of Rectangle))
System.out.print(s[i].get color()}
}

.
.
.
.
.
this is main class.
(i need the other class)
class shape?
class rectangle?
class box?

Answer by ikleyn(52847) About Me  (Show Source):
You can put this solution on YOUR website!
.
Not for this site.