Two of my old assignments! I'm gonna try to finish them. You're welcome to give it a go.
https://web.archive.org/web/20040515162247/http://www.cs.fiu.edu:80/~ege/cop3338/01/assign/two/
https://web.archive.org/web/20040515160953/http://www.cs.fiu.edu/~ege/cop3338/01/assign/three/
An interesting side note here is that these assignments from years ago--- (decades ago!?) -- are still available on the internet, though no longer available at their original URL thanks to the internet archive project!
So, I was delighted to find these assignments archived when I couldn't find them on my professor's web site, I wonder if he's even still teaching there.
Assignment 2 - Reasoning out my approach
I'll start with the Shape as the base class for the other shape classes. All shapes use points, so I'll have a Point class, too, such that the shape can have a point, e.g. a square has 4 Points, each representing as corner. I don't know/recall what Professor Ege had in mind with the concept of a Position but I'm going to assume it is a Point representing where the center of the Shape is within a space on a Canvas. I'll start with a text based user interface (UI) to develop the function and behavior of the Shape classes, Container class, and Dialog class.
Some rules for the Shapes:
A Point is a pair of floating point numbers to represent a location in 2-d space, I.e. (x,y).
A Shape is a geometric figure which has at least one Point which represents its center.
A Rectangle is a Shape, i.e. Square extends Shape, adding four additional Points, each representing a distinct corner. The Points will be considered in a clockwise manner
A Square is a Rectangle for which the each side length is equal, i.e. the distance between two consecutive points is the same floating point value, s.
A Triangle extends Shape by adding 3 Points each representing a distinct corner. The Points will be considered in a clockwise manner.
A Circle extends Shape by adding a radius, r, representing the distance from the Center to each of a conceptually infinite amount of Points which make the circle.
An Elipse extends Shape by adding to radii, p and q, which represents the two perpendicular axes of the shape, then ends of which a continuous line passes through.
The Container is a special data structure which will store the Shapes
corner. The Shapes will be stored in a List (Linked List) since this structure represents an ordered collection. Linked Lists offer add and delete functions.
The Dialog will allow the user to add a Shape of a specified type. Based on the selected type it will prompt the user for the necessary values. The current Shape will be the last one added until the user moves forward or backwards through the Container. The Dialog allows the user to delete the current Shape. The Dialog prints the report about the currently selected Shape.
I started with the Point.java and created this little class. Then I wrote TestBed.java which I will use test each bit of code. This one is just to test using the Point class. it's been a while since I did Java programming so I hacked at it little by little, letting the compile push me to go look up what I didn't remember. TestBed.java looked like this:
# /usr/bin/java TestBedError: Main method not found in class TestBed, please define the main method as:public static void main(String[] args)or a JavaFX application class must extend javafx.application.Application
So I learned to revise the signature of my "main()" method!
I learned that Java has a Point class, already, as well. But I will continue to use mine for this simple project.
I got my test bed to this point and decided it was time to do a "git init":
With the point class fairly well-implemented I will move on to the Shape class.
A Shape is a geometric figure which has at least one Point which represents its center.
Using terms of object orientation, a Shape object aggregates a Point object, meaning the Shape object has a Point (Core Java 2, Horstmann p. 97). The initial Point for a Shape is called its Center.
I've crafted my Shape class as follows:
And the Test Bed as follows, and added the changes to my local git repo:
I think I am at a forking point of what to do next. I have the Shape class implemented. I can either continue down the inheritance path and define the other Shape sub classes, or I can continue start the UI development and work on the Container and Dialog classes because these elements depend on the concept of a Shape, not necessarily the specific implementation of various Shapes.