anonymous
  • anonymous
(Java) Specify, design, and implement a class that can be used to keep track of the position of a location in three-dimensional space.
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
anonymous
  • anonymous
Let's start with a few hints: for 3-dimensional space, how many coordinates would you need to describe the position of a point? Each of those would take the form of a scalar. For such a class, you'll likely want to be able to read and write the respective coordinates - update them when the position of the point changes, read them to find out where it is...
anonymous
  • anonymous
You would need 3 coordinates, xyz.
anonymous
  • anonymous
Exactly! So, those would be data members of your class. Then you'll need methods to access and modify them.

Looking for something else?

Not the answer you are looking for? Search for more explanations.

More answers

anonymous
  • anonymous
This would be a basic class to specify a point. Though it might be useful to make the members public and not use the getter setter methods. class threedcoord { private int x = 0; private int y = 0; private int z = 0; int getx() { return x; } int gety() { return y; } int getz() { return z; } void setx(int inp) { x = inp; } void sety(int inp) { y = inp; } void setz(int inp) { z = inp; } }
anonymous
  • anonymous
while it might seem useful, and may be ok for a small class like this, you should be extremely careful with making data members public. if you ever need to add functionality like logging everytime the position is changed, you would have to change the class and *every instance in your code where you access one of the public members*. once you've written a couple of thousand lines of code using your class in various places, this can become difficult. public data members should only be used in very specific circumstances - some say, data members should never be public.
anonymous
  • anonymous
Oh I see now. Thanks for the responses!
llib_xoc
  • llib_xoc
I absolutely agree with opiesche. What if you write the Point class, refer to the coordinates in lots of places, the decide that the coords need to be *float* numbers? You'll have to change all the references! A great mantra for programming is to organize your code so that you rarely need to change anything in more than one place.

Looking for something else?

Not the answer you are looking for? Search for more explanations.