I'm learning Java after having just come from Haskell, and I'm trying to set up a small class to represent a generic robot. One of the instance variables that I want to add is some kind of representation of the Robot's position.
In Haskell, I would have just done something like:
type Point = (Float, Float)
data Robot = Robot { position :: Point }
but, from what I can tell, Java doesn't have any such aliasing, or tuples, so I'll have to look at it another way.
I thought of just creating another class called Point, and giving it the 2 instance variables "x" and "y" (or, ideally something a little more descriptive), but that seems clumsy. I'll have to define it in it's own file (every class is in a separate file if I correctly recall), and it will only be a few lines long (unless I need to ever add functionality, like "movement").
My other thought was to just do something like:
public class Robot {
...
int xPos;
int yPos;
...
}
which is messier, but more compact.
Basically, this could all be summed up as:
Is it typical in Java to separate a program into a ton of smaller pieces, regardless of the size of the piece? Or, is it typical to group things together if there's little chance of re-use?
(I know that ideally, everything is treated as though it may be re-used in the future, and cut off into a million sub-files, but to what extent should this be followed; especially during initial learning?)