Projection of a Point on X-axis and Y-axis

# Our Objective

Write a Java program to find the projection of a point on the X and Y axes about the topic Defining Methods in Java.

# The Theory

In object-oriented programming, the concept of projecting a point onto the 'x-axis' and 'y-axis' is typically related to 2D geometry or graphics. The projection involves extracting or isolating the 'x' and 'y' components of a given point. Here's a theoretical representation of how you could implement this concept in an object-oriented program.

Let's start by defining a Point class that represents a point in 2D space: Now, we can add methods to the 'Point' class for projecting the point onto the 'x-axis' and 'y-axis':

class Point: The project_onto_x_axis method returns a new 'Point' object with the same x-coordinate as the original point but with a y-coordinate of 0, effectively projecting the point onto the x-axis. Similarly, the project_onto_y_axis method creates a new Point object with a y-coordinate of the original point and an x-coordinate of 0, projecting the point onto the y-axis.

Here's an example usage of the Point class and its projection methods: Output: In this example, we create a Point object 'p' with coordinates (3, 4). We then call the projection methods to obtain the projections of 'p' onto the x-axis and y-axis, which are (3, 0) and (0, 4) respectively.

# Learning Outcomes

• Object-oriented programming: You learn about the fundamentals of object-oriented programming by creating a Point class and defining methods within it to manipulate and project points.
• Method implementation: You learn how to implement methods within a class to perform specific operations. In this case, you see the implementation of methods to project a point onto the x-axis and y-axis.
• Understanding coordinate systems: You gain a better understanding of coordinate systems, particularly how points can be projected onto the x-axis and y-axis.