Results 1 to 7 of 7
- 09-23-2010, 09:42 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 3
- Rep Power
- 0
how i can do this in java main and class point
write a class named Point that include two integer fields x and y and the following methods...
1. a constructor with no parameters that set both x=y=0
2. a constructor with one parameter a that sets x=y=a
3. a constructor with two parameters a,b that sets x=a and y=b
4. two get methods to return x and y
5. two set methods to set a new values to x and y
6. getLocation method which return a string of the location of the point
after that build a main method in which great three points from the three different constructors and print out its x-y values and location
please any one help me i need this program use netbeans
- 09-23-2010, 09:48 PM #2
Have you started writing code for your assignment yet?
If you have any questions, problems or errors, please post them here.
- 09-23-2010, 09:56 PM #3
Member
- Join Date
- Sep 2010
- Posts
- 3
- Rep Power
- 0
in class Point i write this code
Java Code:public class Point { int x,y; /** Creates a new instance of Point */ public Point() { x=y=0; } public Point(int a) { x=y=a; } public Point(int a, int b) { x=a; y=b; } public Integer getX() { return x; } public Integer getY() { return y; } public void setX(int xx) { this.x = xx; } public void setY(int yy) { this.y = yy; } public Point getLocation() { return new Point(x, y); } }
i do not know what i must write in main
please help me
i do not understand this lines i need understand it and code for applay it please
6. getLocation method which return a string of the location of the point
after that build a main method in which great three points from the three different constructors and print out its x-y values and location
please any one help me i need this program use netbeans
- 09-23-2010, 10:27 PM #4getLocation method which return a string of the location of the point
Write a method that returns a String, build some String and return it
- 09-23-2010, 10:49 PM #5
Member
- Join Date
- Sep 2010
- Posts
- 3
- Rep Power
- 0
- 09-23-2010, 11:05 PM #6
Here is a sample get method taken from your code. It uses int vs String so you would need to change where int is used to String and change the value that is returned to be the String you want returned:
Java Code:public Integer getY() { return y; }
- 09-24-2010, 01:55 AM #7
Similar Threads
-
A Polygon class which accepts floating point coordinates
By soorena in forum New To JavaReplies: 2Last Post: 04-01-2009, 08:37 AM -
different multiple public class and main class
By mr idiot in forum New To JavaReplies: 2Last Post: 01-01-2009, 12:10 PM -
[SOLVED] Why main() in java is declared as public static void main?
By piyu.sha in forum New To JavaReplies: 5Last Post: 10-06-2008, 12:11 AM -
How to create main class link to another two class?
By pearllymary78 in forum New To JavaReplies: 6Last Post: 07-16-2008, 11:02 PM -
exception in thred main java.lang.nosuchmethoderror: main
By fernando in forum Java AppletsReplies: 1Last Post: 08-06-2007, 09:11 AM
Bookmarks