Created
February 15, 2014 14:14
-
-
Save stackptr/9019802 to your computer and use it in GitHub Desktop.
readline test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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