problem with my code !!
The file “points.txt” stores the coordinates of two points in two lines, such as
(50, 50) (200, 200)
Write a program to read data from “points.txt” (50%) and draw a colourful square (50%) taking the two points as the corners in the window. Here we assume a 400*400 window and the two pints are within the window.
Hint: In addition to file input, you may need to make use of Processing's standard string manipulation functions/methods split(), substring(), trim() and int().
NEED HELP PLZ
HERE IS MY CODE
BufferedReader shihan;
String s1 , s2;
String s;
String [] coord_pair = new String [2];
int [] x_y = new int [4];
color c;
void setup()
{
size(400,400);
background(255);
c = color (random(0,256),random(0,256),random(0,256));
shihan = createReader("points.text");
s = null;
try
{
// code that creats he erro
s = shihan.readLine();
}
catch(IOException ioe)
{
// code that fixes the error
print(ioe);
}
for (int i = o; i< coord_pair.length; i ++)
{
String [] p1 = new String [2];
p1 = split (coord_pair[i],' , ' ); // 50,50
print (p1);
s1= trim(p1 [0]);
s2= trim(p1 [1]);
x_y [i*2] = int (s1.substring(1));
x_y [i*2+1] = int (s2.substring(0,s2.length()-1));
}
print(x_y);
}
}
void draw()
{
fill(c);
rectMode(CORNER);
rect(x_y[0], x_y[],x_y[2] ,x_y[3]);
}