As a University student studying Computer Science, I am relatively new to many of the concepts that come springing up for me to do battle with (and, with any luck, conquer). Of these, object orientation is quite the tricky one. There are those that say that students who've learnt BASIC are hopeless; while I don't quite subscribe to such an extreme view, making the mental jump from that venerable language of the BBC Micro to Java is quite a hurdle.
It's three o'clock in the morning. My current assignment, due on Thursday, has been not so much a hurdle as a gaping chasm. The previous assignment, to write a class to calculate leap years, was not so terrifying; it came as quite a shock to see the scope of this assignment. In essence, we are to design a ticketing system for a (fictitious) cinema - a task I could quite happily achieve, were it not for the fact that we are so hideously underequipped for the task. Were this a databases assignment, and my tool Access, I would probably be alright. No such luck here - we are, indeed, forbidden from implementing any kind of database functionality at all.
Still, we soldier on and do our best. One part in particular has caused some consternation, though. How does one call a method in a class, from within that class itself? This will, to any veteran Java programmer, seem to be quite the easy feat, but this has left us all scratching our heads in collective bewilderment.
It's three fifteen. David Bowie's Word On A Wing has just started playing, courtesy of iTunes. I sit here staring at my laptop screen, musing the problem.
Inspiration strikes
What if, I think, I use the this keyword? It's certainly worth a shot.
*furious typing, growling at NetBeans to get a move on, finally compiling*
Well that was a pleasant surprise. It works, I celebrate, and the assignment moves slowly onward towards completion.