PointInput.java
Gather user input for coordinates and transformations
Size 2.4 kB - File type text/plainFile contents
// Name: PointInput.java
// Intent: gather user input for coordinates and transformations
// Programmer: John P. Kavanagh #2748 2405
// Date Modified: 12 February 2002
// Audit: Siddharth H Bhatt
import java.io.*;
public class PointInput {
public PointInput () {
try {
String userX;
String userY;
String factor;
String turn;
String userProj;
InputStreamReader inReader;
BufferedReader bReader;
inReader = new InputStreamReader( System.in );
bReader = new BufferedReader (inReader);
// Get user input from command line
System.out.println("");
// Find Coordinates
System.out.println("First, provide the coordinates...");
System.out.println("");
System.out.print("X: ");
userX = bReader.readLine();
System.out.print("Y: ");
userY = bReader.readLine();
// Pass coordinates to point constructor
Point myFirstPoint = new Point(userX, userY);
// Rotate Coordinates
System.out.println("Now, rotate coordinates about axis...");
System.out.println("");
System.out.print("Degrees: ");
turn = bReader.readLine();
// Pass factor to rotate method
myFirstPoint.Rotate(turn);
// Scale Coordinates
System.out.println("Now, scale the point by factor...");
System.out.println("");
System.out.print("Factor: ");
factor = bReader.readLine();
// Pass factor to scale method
myFirstPoint.Scale(factor);
// Translate coordinates
System.out.println("Now, translate point to...");
System.out.println("");
System.out.print("X: ");
userX = bReader.readLine();
System.out.print("Y: ");
userY = bReader.readLine();
// Pass coordinates to method
myFirstPoint.Translate(userX, userY);
// Find coordinate projection
System.out.println("Now, find coordinate projection...");
System.out.println("");
// Request projection from new point object
myFirstPoint.GetProjection();
// Change coordinate projection
System.out.println("Now, change the coordinate projection...");
System.out.println("");
System.out.print("Projection: ");
userProj = bReader.readLine();
// Set projection for new point object
myFirstPoint.SetProjection(userProj);
}
catch(IOException e) {
System.out.println("ERROR gathering user input.");
}
}
}
Click here to get the file