Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

(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
See more answers at
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.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

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...
You would need 3 coordinates, xyz.
Exactly! So, those would be data members of your class. Then you'll need methods to access and modify them.

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

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; } }
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.
Oh I see now. Thanks for the responses!
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.

Not the answer you are looking for?

Search for more explanations.

Ask your own question