Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

java

Name: Anonymous 2010-03-01 7:31

word1 = scan.next();
word2 = scan.next();
word3 = scan.next();
Person [] p = personlist.getPersons();

if (word1.equals("add")) {
    personlist.addPerson(word2,word3);
}
if (word1.equals("show")) {
    for (int i = 0; i < p.length; i++) {
        if (word2.equals(p[i].name)) {
        System.out.println("Navn " + p[i].name);
        System.out.println("Nummer " + p[i].phone);
        System.out.println("Antall venner: " + p[i].friendList.getPersons().length);
        }
    }
/*System.out.println("Navn " + personlist.getPerson(word2).name);
System.out.println("Nummer " + personlist.getPerson(word2).phone);
System.out.println("Antall venner " + personlist.getPerson(word2).friendList.getPersons().length);
*/
}

Why did I have to comment out the last part and use the p array loop. The getPerson() does work, just not in this case, any idea?

Name: Anonymous 2010-03-01 7:39

>>1
why did you not use [code] tags?

Name: Anonymous 2010-03-01 8:04

I don't see the declaration of personlist. Or the implementation of getPerson, for that matter. Or anything of even remote interest.

Name: Anonymous 2010-03-01 8:17

Nothing ruins my day more than to see Java code being posted on /prog/. Not to mention that OP didn't even freaking use [code][/code] tags.

Name: Anonymous 2010-03-01 10:34

Have you read your SICP?

Name: Anonymous 2010-03-01 11:15

>>1
You might want to wrap that commented-out block in a try { ... } catch(NullPointerException e) { } statement.  word1 may not always be "add," in which case you're searching personlist for a word2 that doesn't exist, but proceeding forward with it as if it did exist.  I don't know what the base case of getPerson(String) returns but I'm assuming null if it finds nothing.

If you're going to run with that for loop anyway, unless you allow redundant entries in personlist, break after you find the right person and have outputted their information.

If you're not going to include pertinent source code, methods, etc., do properly explain what it does and what it returns.

Name: Anonymous 2010-03-01 11:41

>>6
DHTH (Don't help the trolls).

Name: Anonymous 2010-03-01 12:11

>>6
DHPWCT (Don't help people without [code] tags)

Name: Anonymous 2010-03-01 12:27

Pig disgusting Danish.

Name: Anonymous 2010-03-01 12:30

>>8
suck my dick fag

Name: Anonymous 2010-03-01 12:36

>>8
DEYRA (Don't explain you 're acronyms).

Name: Anonymous 2010-03-01 12:43

>>11
EXPLAIN MY ANUS

Name: Anonymous 2010-03-01 12:58

sup bjarne

Name: Anonymous 2011-02-03 5:42

Don't change these.
Name: Email:
Entire Thread Thread List