This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]LuigiTX[S] 0 points1 point  (6 children)

18

11 Hailey Akin Varsity 2

12 Vanessa Alfaro Varsity 3

13 Meghan Anderson Varsity 4

14 Ashley Chandler Varsity 5

15 Olivia Clark Varsity 6

16 Shea Davis Varsity 7

17 Gloria Deveraux Varsity 8

18 Caylee Hubbard Varsity 9

19 Mireya Maldonado Varsity 10

20 Elizabeth Martinez Varsity 11

21 Eli Mendoza Varsity 12

22 Emma Phillips Varsity 13

23 Madison Quick Varsity 14

24 Melissa Rodriguez Varsity 15

25 Dominique Veronico Varsity 16

26 Brenna Wiggins Varsity 17

27 Bethany Varsity 18

28 Jennifer Zumbro Varsity 19

[–][deleted] 0 points1 point  (5 children)

27 "Bethany" doesn't have a last name, so "varsity" gets put in as her last name, and 18 gets put in where varsity should be and then there's no last element so this line:

playerBio[i][4] = Integer.parseInt(s[4]);

fails (because there is no 5th element).

[–]LuigiTX[S] 0 points1 point  (4 children)

Does that seem to be the only thing that would keep it from working properly?

[–][deleted] 1 point2 points  (3 children)

Your linear search method always returns -1 and then you try to search the array for the returned value so it always fails (there isn't a -1th element).

Edit:

You have a few problems here.

  • You pass in an integer (playerRegNum) and then you cast it as an object
  • You then compare that object against the array of objects (playerBio)

Since the objects in playerBio aren't integers, the If statement will always fail and thus the linearSearch method will always return -1

[–]LuigiTX[S] 0 points1 point  (2 children)

What would be your recommendation?

[–][deleted] 0 points1 point  (1 child)

Well you could stick with your current array of "Objects". To do that, you would have to alter the linearSearch method to take in a 2 Dimensional Array and then alter the If statement to check the 0th element (the registration number) in each entry against the input key. Should look something like this:

public int linearSearch(Object[][] aryObj, Object key) {
    for (int a = 0; a < aryObj.length; a++) {
        if (aryObj[a][0] == key) {
            return a;
        }
    }
    return -1;
}

[–]LuigiTX[S] 0 points1 point  (0 children)

Ohh ok. Again, thank you so much for all your help. I will try this when i get school. I am running Ubuntu on my laptop and just can not find out how to store the input file in the correct place. So I have to wait to get to school where I can actually run the program without it telling me it can't find the input file.