0

I did this code ( this here is just a piece of it), and there's supposedly an incomplete function in there.
I'm not sure what how to solve this. I suppose the boolean is wrong? I indicated where the problem is in the code.

public class Person
{
    private String firstName;
    private String lastName;
    private String ID; // user ID
    private String password;
    private int   userType; // 1 student 2 faculty


    public Person()
    {

    }
    public Person(String ID, String firstName, String lastName, String password, int   userType)
    {
        this.ID        = ID;
        this.firstName = firstName;
        this.lastName  = lastName;
        this.password  = password;
        this.userType  = userType;//1 faculty 2 student
    }
    public String toString()
    {
        return ID+ " " +  Application.addSpaces((firstName + " " + lastName),18);
    }
    public boolean equals(Object theOtherObject)
    {
        // YOU CAN CHANGE EVERYTHING IN THIS FUNCTION INCLUDING THE STAMENTS:
        // boolean result = false;
        // return result;

        boolean result = false;
        // INCOMPLETE FUNCTION
        // ooooooooooooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // ooooooooooooooooooo
        // oooooooo  ooooooooo
        // ooooooooooooooooooo

        return result;
    }
    public boolean validation(String ID, String password)
    {
        return ( this.ID.equals(ID)&& this.password.equals(password) );
    }
    public int getUserType()
    {
        return userType;
    }
    public String getUserID()
    {
        return ID;
    }
}

The same with this one here:

public class Application
{
    private Scanner keyboard;
    private Person[] userDatabase;
    private Course[] courseDatabase;
    private int numberOfUsers;
    private int numberOfCourses;
    private Person currentUserObject;
    public static String addSpaces(String input, int fullLength)
    {
        String output= input;
        int extraZeros = fullLength-input.length();
        for(int i=0; i<extraZeros; i++)
        {
            output = output +" ";
        }
        return output;

    }
    public Application()
    {
        
        currentUserObject = null;
        userDatabase    = new  Person[20];
        courseDatabase  = new  Course[10];
        numberOfUsers   = 0;
        numberOfCourses = 0;
        keyboard = new Scanner(System.in);
        addRecords();

    }
    private void addRecords()
    {
        // Create Users
        userDatabase[numberOfUsers++] = new Student("92038201",  "Ilyas",   "Uyanik", "Computer Science", "1956",       2, 1);//0
        userDatabase[numberOfUsers++] = new Student("20483002", "Joseph",   "Mathew", "Computer Science", "1234",       3, 1);//1
        userDatabase[numberOfUsers++] = new Student("26023923",  "Suzan",     "Pink", "Computer Science", "2342",       3, 1);//2
        userDatabase[numberOfUsers++] = new Student("34532343",    "Amy",   "Yellow", "Computer Science", "4533",       1, 1);//3
        userDatabase[numberOfUsers++] = new Student("78643546", "George",    "Black", "Computer Science", "0495",       4, 1);//4
        userDatabase[numberOfUsers++] = new Student("45345753",  "Fatih", "Haberdar", "Computer Science", "5478",       1, 1);//5
        userDatabase[numberOfUsers++] = new Student("23748967",  "Murat",  "Erdogan", "Computer Science", "9043",       2, 1);//6
        userDatabase[numberOfUsers++] = new Student("32946262",    "Sam",     "Blue", "Computer Science", "3241",       4, 1);//7
        

        userDatabase[numberOfUsers++] = new Faculty("52037101",  "Hakan", "Haberdar", "Computer Science", "1267",  70000.0, 2);//8
        userDatabase[numberOfUsers++] = new Faculty("30293102",   "Bill",    "Brown", "Computer Science", "7810", 100000.0, 2);//9
        userDatabase[numberOfUsers++] = new Faculty("10132103",   "John",    "White", "Computer Science", "3724",  60000.0, 2);//10
        userDatabase[numberOfUsers++] = new Faculty("32546104",   "Ayse",      "Red", "Computer Science", "2938",  80000.0, 2);//11
        userDatabase[numberOfUsers++] = new Faculty("98232105",   "Emre",    "Charu", "Computer Science", "2302",  83000.0, 2);//12
        // Create Courses
        courseDatabase[numberOfCourses++] = new Course("1320", "Intro to Computer Science", "52037101", 4);
        courseDatabase[numberOfCourses++] = new Course("1410", "Data Structures", "10132103", 4);
        courseDatabase[numberOfCourses++] = new Course("2430", "Artificial Intelligence", "32546104", 3);
        // Enrollment
        ((Student)userDatabase[0]).addClass(courseDatabase[0]);
        ((Student)userDatabase[1]).addClass(courseDatabase[0]);
        ((Student)userDatabase[2]).addClass(courseDatabase[0]);
        ((Student)userDatabase[3]).addClass(courseDatabase[0]); // 1320, full

        ((Student)userDatabase[4]).addClass(courseDatabase[1]);
        ((Student)userDatabase[5]).addClass(courseDatabase[1]); // 1410, 2 available

        ((Student)userDatabase[6]).addClass(courseDatabase[2]);
        ((Student)userDatabase[7]).addClass(courseDatabase[2]); // 2430, 1 available
    }
    private int existingCourse(String courseNumber)
    {
        int result = -1;
        for(int i=0; i<numberOfCourses;i++)
        {
            if( courseDatabase[i].getNumber().equals(courseNumber) )
            {
                result = i;
            }
        }
        return result;

    }
    private boolean existingUser(String ID)
    {
        // RETURN FALSE IF THERE IS NO USER WITH THE GIVEN ID
        // RETURN TRUE OTHERWISE
        // YOU CAN CHANGE EVERYTHING IN THIS FUNCTION INCLUDING THE STAMENTS:
        // boolean result = false;
        // return result;
        boolean result = false;
        // INCOMPLETE FUNCTION
        // ooooooooooooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // oooooooo  ooooooooo
        // ooooooooooooooooooo
        // oooooooo  ooooooooo
        // ooooooooooooooooooo
        return result;

What is wrong with the boolean?

Edited by XodoX: n/a

1
Contributor
1
Reply
2
Views
5 Years
Discussion Span
Last Post by XodoX
0

Could that be it? For the first one?

Person p1 = new Person("1", "Jim", "Jones", "JJ", 1);
Person p2 = new Person("1", "Jim", "Jones", "JJ", 2);

p1.equals(p2); //tests equality

Person[] people = new Person[]{p1, p2};
Arrays.sort(people);

And just input all the names from #2?

Edited by XodoX: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.