Garrett, i revised my codes coz i figure out its all messed up, thanks for your help..now in my new code i think its more clear but im having a new set of errors and i need your help again, sorry im trying and im really new in
java..
[code]
import java.io.*;
class Students implements Comparable
{
private String firstName, lastName, name1, name2;
private int credits;
private double gradePointAverage;
private boolean nullStudent = false;
// The exception thrown for names without a space
// separating the first name and last name
public class NameFormatError extends IOException {}
public int compareTo(Object other)
{
Student otherStudent = (Student)other;
String name1 = lastName + firstName;
String name2 = otherStudent.lastName + otherStudent.firstName;
return name1.compareTo(name2);
}
public boolean equals(Comparable other)
{
if (!(other instanceof Student))
return false;
Student o = (Student)other;
return name1.equals(o.name1) && name2.equals(o.name2);
}
public boolean isNull()
{
return nullStudent;
}
public void input(BufferedReader reader) throws IOException
{
String line = reader.readLine();
if (line == null)
{
nullStudent = true;
return;
}
//indexOf() and substring();
{
if (line == null)
return;
int space = line.indexOf(' ');
if (space < 0)
throw new NameFormatError();
firstName = (line.substring(0, space));
int space2 = line.indexOf(' ', space + 1);
lastName = (line.substring(space + 1, space2));
space = line.indexOf(' ', space2 + 1);
credits = Integer.parseInt(line.substring(space2 + 1, space));
gradePointAverage = Double.parseDouble(line.substring(space + 1));
{
System.out.println(firstName + ", " + lastName + " " + credits + " " +
gradePointAverage);
}
}
}
}
[\code]
errors im getting:
lastName has private access in Students
firstname has private access in Students
name1 has private access in Students
name2 has private access in Students..
plz bare with me i really need help..thanks much..
[ February 19, 2006: Message edited by: jayson clark ]