import java.io.*;
import java.nio.file.*;
import java.nio.charset.Charset;
import static java.nio.file.StandardCopyOption.*;
import java.io.Console;
class linkedlist {
public linkedlist next;
public linkedlist previous;
public String data;
}
class person {
public int height = 0; //height in inches
public int weight = 0; //weight in pounds
public String eyecolor = null; // eye color
public String weight_status = null; // very skinny, skinny, medium, fat, very fat
public String name = null;
linkedlist attributes = new linkedlist();
public person(int height1, int weight1, String eyecolor1, String weight_status1, String name1, linkedlist previous1, linkedlist next1) {
height = height1;
weight = weight1;
eyecolor = eyecolor1;
weight_status = weight_status1;
name = name1;
attributes.previous = previous1;
attributes.next = next1;
}
public person () {
}
}
public class person_manager {
static File file = new File("C:\\Documents and Settings\\Administrator\\My Documents\\sorted_list.txt");
static File file2 = new File("C:\\Documents and Settings\\Administrator\\My Documents\\the_person_modification_database.txt");
static StringBuffer contents = new StringBuffer();
static BufferedReader reader = null;
static BufferedReader reader1 = null;
static int count = 0;
static int listlength = 0;
static String[] list = null;
static String temp1 = null;
static Path file1 = FileSystems.getDefault().getPath("C:\\Documents and Settings\\Administrator\\My Documents\\", "sorted_list.txt");
static person[] people_array = null;
static int arraysize = 0;
//60
public static void main(String[] args) throws IOException {
try {
reader = new BufferedReader(new FileReader(file2));
reader1 = new BufferedReader(new FileReader(file2));
String text = null;
// repeat until all lines are read
while ((text = reader.readLine()) != null) {
contents.append(text).append(System.getProperty("line.separator"));
count++;
}
list = new String[count];
people_array = new person[count];
arraysize = count;
count = 0;
while ((temp1 = reader1.readLine()) != null) {
people_array[count] = new person();
people_array[count].name = temp1;
//System.out.println(people_array[count].name);
if (temp1.substring(0, 2).compareTo("na") == 0 )
{people_array[count].name=temp1.substring(5, temp1.length());}
try {
if (temp1.substring(0, 2).compareTo("he") == 0 )
{people_array[count].height=Integer.parseInt(temp1.substring(7, temp1.length()));}
} catch (NumberFormatException f) {people_array[count].height=0;}
try {
if (temp1.substring(0, 2).compareTo("we") == 0 && (temp1.substring(6, 7).compareTo("-") != 0) )
{
people_array[count].weight=Integer.parseInt(temp1.substring(7, temp1.length()));}
} catch (NumberFormatException f) {people_array[count].weight=0;}
if (temp1.substring(0, 2).compareTo("ey") == 0)
{people_array[count].eyecolor=temp1.substring(10, temp1.length());}
if (temp1.substring(0, 7).compareTo("weight-") == 0)
{people_array[count].weight_status=temp1.substring(14, temp1.length());}
if (temp1.substring(0, 2).compareTo("at") == 0) {
if (temp1.substring(0, 10).compareTo("attributes") == 0) {
people_array[count].attributes.data = temp1;
} else { people_array[count].attributes.data = temp1.substring(10, temp1.length());}
}
else { }
count++;
}
listlength = count;
} catch (FileNotFoundException e) { e.printStackTrace(); }
catch (IOException e) { e.printStackTrace(); }
finally { try { if (reader != null) { reader.close();} } catch (IOException e) { e.printStackTrace(); } }
//addData();
savelist();
}
public static void savelist () throws IOException {
PrintStream out = new PrintStream(new FileOutputStream("C:\\Documents and Settings\\Administrator\\My Documents\\testing1.txt"));
for (int i = 0 ; i < listlength ; i++) {
System.out.println(people_array[i].name);
}
}
}