Week 7 Airport Exercise issue

133 views
Skip to first unread message

Timothy Walter

unread,
Aug 12, 2015, 11:18:18 PM8/12/15
to mooc.fi
Hi,

I'm having problems with week 7 exercise 8.

I am getting a null pointer exception on line 35 of my UI class when it tries to send variables to  a method of another class. I have compared my code against the previous exercise and can't see where i went wrong. Any ideas?


The link to my work is here: 

Best regards
Tim.

Timothy Walter

unread,
Aug 12, 2015, 11:21:18 PM8/12/15
to mooc.fi
The error would be on line 34 of TMC.

Joni

unread,
Aug 13, 2015, 2:53:30 AM8/13/15
to mooc.fi
Hi,

Looking at your UI.java constructor I see this:
this.airplanes=airplanes;

Now your constructor declarator is this:
public UI(Scanner reader, Airplanes airplane, Flights flights) {

airplane != airplanes so basically you are saysin this.airplanes = this.airplanes which is why airplanes is null :)

Best regards
Joni

Timothy Walter

unread,
Aug 13, 2015, 3:19:29 PM8/13/15
to mooc.fi

Thank you, that completely fixed it. Drove me crazy as i couldn't see what could be causing the error. I guess I'll make sure to check for things like that in the future.
Reply all
Reply to author
Forward
0 new messages