Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating classes for entity names, has-a relationships

 
Tia Rambaran
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48453
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic