wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Creating classes for entity names, has-a relationships Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating classes for entity names, has-a relationships" Watch "Creating classes for entity names, has-a relationships" New topic
Author

Creating classes for entity names, has-a relationships

Tia Rambaran
Greenhorn

Joined: Feb 24, 2010
Posts: 1
Hi there! I'm very confused over java right now. I'm a beginner and (my prof hardly speaks English). In our assignment, we need to take some entities and create a java class/constructor and show how to instantiate them.

Here are two entities I'm currently stuck on.



For the Coordinate class, I've written:



This was following an example given to us.
However, I'm pretty sure something about it is incorrect in the instantiation..

I did a similar thing with the circle class, but something tells me I have to use a "has-a" relationship?
Or maybe I would use "has-a" only for another entity (Cat [head {Circle}, body {Rectangle}, feet {Line[4]}, tail {Line}]). which probably makes more sense...
And even then, I don't know how to go about doing that.

A little guidance would be much appreciated Thanks in advanced.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not sure what your instructor is aiming for here, and the constructs used to give you your requirements may be tripping you up.

The first step is to get code to compile--does your Coordinate class compile? If not, that'd be the first step.

The second step is to determine what you're actually trying to do--and where/when. When do you want to instantiate a coordinate? Are x and y ints, or floats? Does the Circle class exist yet? What might it look like?

One step at a time :)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
Welcome to the Ranch

Have a look at the instructions given; they tell you what type x and y should be. You have actually declared them twice, so that will cause problems. You will have to keep only one x and one y.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Creating classes for entity names, has-a relationships
 
Similar Threads
Why does it not show the new coordinates?!!??!!
How to read from all files in a directory & plot the contents by processing contents?
Event Handlers:Mouse over "circles"
MousePressed
"Shadowing" fields