^wala ko ka-kuha ana nga command dah.. hehe. unsa na ang "copy con" nga command?
akong package directory kay naa sa C:\Java\Packages, nya akong main program naa sa My Documents...
naa pud ko lain question, lahi na topic pero ari lang ko post. hehe.
nag himo ko lain .java file sa package, Rectangle.java, nya naa koy main program, MyRect.java. Post lang nako ang code.. hehe.
Rectangle.java
Code:
package Geometry;
public class Rectangle{
public Rectangle(){
point[0].setPoints(0,0);
point[1].setPoints(1,0);
point[2].setPoints(0,1);
point[3].setPoints(1,1);
}
public Rectangle(double point1_x,double point1_y,double point2_x, double point2_y){
point[0].setPoints(point1_x, point1_y);
point[3].setPoints(point2_x, point2_y);
point[1].setPoints(point2_x, point1_y);
point[2].setPoints(point1_x, point2_y);
}
public Rectangle(final Rectangle oldRect){
point[0] = oldRect.point[0];
point[3] = oldRect.point[3];
point[1] = oldRect.point[1];
point[2] = oldRect.point[2];
}
public double getWidth(){
return point[0].distance(point[1]);
}
public static void printRectangle(final Rectangle rect){
for(int i= 0;i<4;i++){
System.out.println("Corner"+(i+1)+" X: "+rect.point[i].getX()+" Corner"+(i+1)+" Y: "+rect.point[i].getY());
}
System.out.println();
}
Point[] point = new Point[4];
}
MyRect.java
Code:
import Geometry.*;
public class MyRect{
public static void main(String[] args){
Rectangle myRect = new Rectangle(0,0,2,1);
Rectangle copyRect = new Rectangle(myRect);
printRectangle(myRect);
double width = myRect.getWidth();
}
}
mag-error lagi og "Symbol not found"? ang methods nako (printRectangle, getWidth) kay dil ma-work..