Question

JAVA. The question mentioned was: Create a class called Point that represents a point in the...

JAVA. The question mentioned was: Create a class called Point that represents a point in the cartesian coordinate system. The class should have fields representing the x coordinate and y coordinate (both are integer type).

Question I need an answer to: Write a client class that would create two objects in the Point class above called p1 and p2 and assigns values to the filed in these objects. Print out the x coordinate followed by x comma and last coordinate enclosed by parenthesis for each object.

For example if for a point x=40, any y=50 the output should be (40,50).

Homework Answers

Answer #1

If you have any doubts comment below

Output

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent...
do (iii) and (iv) (i) This is a simple Point class interface file whose objects represent points in the cartesian plane #include <iostream> using namespace std; class Point { public:     Point()      // default constructor         Point(double x, double y); // another constructor         double x() const; // get function, return _x         double y() const; // get function, return _y private:         double _x, _y; }; (ii) Here is a test driver file for the Point class...
Java code Problem 1. Create a Point class to hold x and y values for a...
Java code Problem 1. Create a Point class to hold x and y values for a point. Create methods show(), add() and subtract() to display the Point x and y values, and add and subtract point coordinates. Tip: Keep x and y separate in the calculation. Create another class Shape, which will form the basis of a set of shapes. The Shape class will contain default functions to calculate area and circumference of the shape, and provide the coordinates (Points)...
public class Point { int x; int y; public Point(int initialX, int initialY){ x = initialX;...
public class Point { int x; int y; public Point(int initialX, int initialY){ x = initialX; y= initialY; } public boolean equals (Object o){ if (o instanceof Point){ Point other = (Point)o; return (x == other.x && y == other.y); }else{ return false; } } } We haev defined "equals" method for our class using "instanceof". We define and use instances (or objects) of this class in the following scenarios. In each case, specify what is the output. (hint: there...
In java //Create a New Project called LastNameTicTacToe.// //Write a class (and a client class to...
In java //Create a New Project called LastNameTicTacToe.// //Write a class (and a client class to test it) that encapsulates a tic-tac-toe board. // A tic-tac-toe board looks like a table of three rows and three columns partially or completely filled with the characters X and O. // At any point, a cell of that table could be empty or could contain an X or an O. You should have one instance variable, a two-dimensional array of values representing the...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
IN C++ - most of this is done it's just missing the bolded part... Write a...
IN C++ - most of this is done it's just missing the bolded part... Write a program that creates a class hierarchy for simple geometry. Start with a Point class to hold x and y values of a point. Overload the << operator to print point values, and the + and – operators to add and subtract point coordinates (Hint: keep x and y separate in the calculation). Create a pure abstract base class Shape, which will form the basis...
Coding in Java Create an Airplane class (not abstract) that uses the Vehicle interface in Q1....
Coding in Java Create an Airplane class (not abstract) that uses the Vehicle interface in Q1. The code for all methods should print simple messages to the screen using System.out.println(). Add an integer speed variable that is changed using ChangeSpeed method. ChangeSpeed adds 5 to the speed each time it is called. Create a default constructor that sets the initial speed to 0. Don't create other constructors or any setter/getter methods. // code from Q1: interface Vehicle { void Start();...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String),...
Create a class called Employee that contains three instance variables (First Name (String), Last Name (String), Monthly Salary (double)). Create a constructor that initializes these variables. Define set and get methods for each variable. If the monthly salary is not positive, do not set the salary. Create a separate test class called EmployeeTest that will use the Employee class. By running this class, create two employees (Employee object) and print the annual salary of each employee (object). Then set the...
A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class,...
A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a class, “pointType”, that can store and process a point in the x-y plane. You should then perform operations on the point, such as setting the coordinates of the point, printing the coordinates of the point, returning thex-coordinate, and returning the y-coordinate. Also, write a program to testvarious operations on the point. x-y plane and you designed the class to capture the properties of a point...
The following is for a Java Program Create UML Class Diagram for these 4 java classes....
The following is for a Java Program Create UML Class Diagram for these 4 java classes. The diagram should include: 1) All instance variables, including type and access specifier (+, -); 2) All methods, including parameter list, return type and access specifier (+, -); 3) Include Generalization and Aggregation where appropriate. Java Classes description: 1. User Class 1.1 Subclass of Account class. 1.2 Instance variables __ 1.2.1 username – String __ 1.2.2 fullName – String __ 1.2.3 deptCode – int...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT