Composition JAVA Programming HELP (Im new to java)

I'm 16 yrs old and I just started programming as a hobby. In need help in how do to create an application that uses composition. I have a Point class which will maintain a point,that is, an x and y coordinate. Also I don't know how to create a Line class which will contain two Point data members. Line will have the logic to determine the equation of the line such as having methods to calculate the slope, y-intercept, and display the final equation.

The application itself will use the Point and Line classes. The application should have minimal logic such as only creating objects and calling methods.

Re: Composition JAVA Programming HELP (Im new to java)

Nice Hobby. Programming is lots of fun. Regarding your question, I am not certain what you mean by composition programming. There is a design pattern called the composite design pattern where instead of using inheritance, you use instances of a class and then provide public forwarding methods for those instances. So if you could provide some more info I might be able to offer some help.

However, I can make one recommendation. Unless you really need them to be public, make your class fields private. After all, that is why you have getters and setters.