# Last weeks college java programming question I did not understand how to do

This is an old question and I have already taken a 0 for my score on it, but I'd still like to know how it is done, It is puzzling me. Any help would be appreciated. It goes like this:

Rewrite the following code

1 // Fig. 9.5: PointTest.cs
2 // Testing class Point.
3
4 using System;
5 using System.Windows.Forms;
6
7 // PointTest class definition
8 class PointTest
9 {
10 // main entry point for application
11 static void Main( string[] args )
12 {
13 // instantiate Point object
14 Point point = new Point( 72, 115 );
15
16 // display point coordinates via X and Y properties
17 string output = "X coordinate is " + point.X +
18 "\n" + "Y coordinate is " + point.Y;
19
20 point.X = 10; // set x-coordinate via X property
21 point.Y = 10; // set y-coordinate via Y property
22
23 // display new point value
24 output += "\n\nThe new location of point is " + point;
25
26 MessageBox.Show( output, "Demonstrating Class Point" );
27
28 } // end method Main
29
30 } // end class PointTest

To complete this exercise, rewrite the case study of Section 9.5 as a Point-Square-Cube hierarchy with inheritacne. In other word, which class should be parent or superclass and which should be not?
Use the Shape abstract class (see below) as top level parent. The Shape class capture two common behaviors such as computing an area and volume. Each child class must override these two methods to provide its own verion of the area and volume. For example, the formula for computing the area of the point is quite different from square. In addition, each child class must provide a concrete implementation of the getName() method.
public abstract class InheritanceShape {
// no constructor is needed because this class is abstract
public double area() {
return 0.0;
}
public double volume() {
return 0.0;
}
// in order for subclasses to be concrete, they will have
// to define getName()
public abstract String getName();
} // end class InheritanceShape
The output should look similar to:

###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
If you've already taken a 0 for the assignment, you would be better to ask your tutor for the model solution and clarify your questions with them one-to-one.

At least it will show you were interested in the question.  If you don't ask your tutor, it's going to look like you can't be bothered (which won't stand you in good stead for future assignments).
0
Commented:
You posted a C# source code and you tell something about a Java course.
Try using a java.awt.Point instead of a Windows.System.Forms.Point

import java.awt.*;
replace all string by String
replace all .X by .x and .Y by .y
Don't know a synonym for Messagebox.Show right now. You could try System.out.println()
Make the class and the Main-Method public

Point-square-cube hierarchy:
Inheritance is normally done by expansion, not by restiction. A cube is most complex, so it is neither parent of a point nor a square. Also, a square is more complex than a point and therefore should not be parent of point.
In my eyes, you can do it like

InheritanceShape
Point   Square    Cube

or like

InheritanceShape
Point
Square
Cube
0
Commented:
sounds like a homework question reworded
0

Experts Exchange Solution brought to you by