Monday 15 March 2010

java - Logical stuck in my project -


Since I get my previous questions about the erroroutfound error but resolves (there is no hard feeling: D but it My first question was, so you should expect some "mistakes") Anyway I'm going to try one more time with another question. This is a project-drill in which my programming II Lab exam was for lessons. Firstly it requires a class named Point, which describes a point with the X and Y coordinate (piece of cake) in 2th place.

More, it is called a line (in general, there is 2 points in a row 2-D space) (is it necessary that class line gets a class point?) And 2-D space With 2 points (piece of cake too). In addition, it requires a method called zero movement (Point, Point) which will move the line (and starts stranded here: D).

Finally, it needs to create a main square with 3 objects A, B, C points (using 2 constructs in the class point) and then print the point B information on the screen. After that it is required to form 2 objects as D, E lines and lines need to be started with D with 0 values ​​and line E along with points A and B. To continue with this, it is necessary to print the information of line e on the screen (still good), but then we want to move line e in a way so that it can cross the point (1,1) , Which will be the point and my problem lies here, in the end it wants us to print new information on line E on screen. Could you point me in the right direction? Thanks!

To avoid confusions like people in my previous question, the complete code I have made up till now is below.

  public square point {protected double x; Protected double y; Public point () {// first constructor-no arguments} Public point (double x1, double y1) {// second constructor-2 argument x = x1; Y = y1; } Public Zero setX (int x1) {x = x1; } Public Double getX () {Return x; } Public Zero Set Y (Int y1) {y = y1; } Public double getY () {return y; } Public string toasting () {return "(" + + "," + y + ")"; }}   

class line

  public class line point (private point pStart; private pointpoint; public line () {// first constructor-no arguments } Public Point (Point P1, Point P2) {// Second Constructor-2 Logic pStart = p1; Pend = P2;} Public Zero Setstart Point (Point P1) {pStart = p1;} Public Point GetStartPoint () {Return pStart;} Public Zero Set Endpoint (Point P2) {Pd = P2;} Public Drugg getEndPoint () {returnpind;} public string toting () {"starting line of line:" + pStart.toString () + "\ t" + "End of line:" + pEnd.toString ();} public Zero strike (point p, point mp) {// my problem: dp.x + = mpx; py = mp.y;}}   

main square

Thank you for reading this. I am waiting for your reply.

Continued from my comment, to include e line e (i.e. cross) point (1, 1) For either , the paste or pend must be equal to (1, 1).

No comments:

Post a Comment