Skip to content

Instantly share code, notes, and snippets.

@stackptr
Created February 15, 2014 14:14
Show Gist options
  • Save stackptr/9019802 to your computer and use it in GitHub Desktop.
Save stackptr/9019802 to your computer and use it in GitHub Desktop.
readline test
var rl = require('readline').createInterface({
input: process.stdin,
output: process.stdout
});
function Point(x, y){
this.x = x;
this.y = y;
}
// Parse some coordinate "[-]xx,[-]yy" into a Point
function parsePoint(str){
str = str.trim().split(",");
var x = parseFloat(str[0]),
y = parseFloat(str[1]);
return new Point(x, y);
};
var A, B, C, D;
rl.question("Point A (x,y): ", function(res){
A = parsePoint(res);
rl.close();
});
rl.question("Point B (x,y): ", function(res){
B = parsePoint(res);
rl.close();
});
rl.question("Point C (x,y): ", function(res){
C = parsePoint(res);
rl.close();
});
rl.question("Point D (x,y): ", function(res){
D = parsePoint(res);
rl.close();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment