Code Code Code
Now, said psychotic ex roommate is earning somewhere in the neighborhood of 25% more than I am without having ever finished his college degree, and I’m trying to figure out this Java stuff.
What’s bothering me at the moment is that I cannot figure out what the hell is wrong with this code, which I wrote for the second assignment. I’ve written more complicated code in Java in the past, but it can’t hurt to go over the basics one more time, right? This bit of code includes a class that I downloaded from the instructor’s website and which I compiled in the same directory as my code. I made sure to tell the compiler that the directory my code is indeed, God’s truth, in the CLASSPATH variable. And yet something is going wrong. Here’s the code. See if you can figure it out:
class Assignment_02
{
int age;
String inText;Assignment_02()
{
System.out.print("Enter age: ");
inText = Term.input();age = Term.atoi(inText);
if (age < 16)
System.out.println("This person is under 16");
else if (age < 18)
System.out.println("This person is under 18");
else
System.out.println("This person is over 18");
}public static void main(String[] args)
{
Assignment_02 myProg = new Assignment_02();
}
}
I swear, the only thing that differs between my code and the instructor’s code is the class name. I’ve compiled this stupid thing a dozen times. It compiles fine, but when I try to execute the code, I get an error that reads, "Exception in thread main: no such class as Assignment_02, you idiot." Verbatim. My compiler doesn’t pull punches.
I know what’s going to happen. I’m going to fuss over this code all night while Jennifer happily bakes brownies in the kitchen and the cats chew on my socks, and I am going to go to bed convinced that I have missed some secret alchemical device known to the course instructor and a handful of Illuminati in Bavaria. And tomorrow morning I am going to wake up early, go swimming, and just as I complete my fourth lap I’m going to leap out of the swimming pool shouting "EUREKA!" and come running back to the house and log into my computer and fire up my editor and make a single change in the code, probably a single character somewhere, and recompile the damn thing and run it, only to have the same error come back into my face. "No such class as Assignment_02, asshole. You might as well practice saying, ‘You want fries with that?’"
This is just like dating. Except that when you’re in the dating process, you sometimes get it right. It’s my considered opinion that no one ever writes a Java program succesfully, it’s just that the compiler gets tired of fighting back.
I have a tendency to catastrophize. It’s not that I’m having trouble seeing where my error is in this code (and it might be as simple as having to recompile the stupid code with the instructor’s home-grown Term class); it’s that I’m the stupidest person who has ever walked the face of the earth and a Bushman in southern Africa who has no idea that Coca Cola exists, let alone platform-independent web-enabled object-oriented languages, has a better shot at building up their IT career than I do.
If I’d been thinking when I was living in the dorms with my psychotic roommate, I would have punched him in the face when he blathered about how wonderful Pascal was. I would have done it cheerfully (and I can actually think of a couple of people who would, to this day, happily hold him down while I did so), explaining, "This is for all those programs I’m going to write that are never going to compile!"
On a more positive note, things are actually looking up for me at work. I’ve wormed my way in to the PDA development project, thanks mostly to the fact that the local lead developer likes me. When I asked him what skill set he’d like to see, he replied, "Familiarity with Code Warrior." I explained that I’d never touched Code Warrior, although I’ve seen the box on the shelf. He replied, "Oh, that’s okay, we’ve got a spare license and can install it on your laptop tomorrow. So be sure to bring it in." It was a positive note for me. On the other hand, I have a limited period of time now to learn enough C++ to make a Palm Pilot application work (and in that same period of time I need to figure out how to deflect enough work from me and on to another developer so that I’ll have time to learn C++ and get involved in the PDA development project); and this will make my experience with Java a lot more interesting. And I’m committed to learning Java, for a lot of very good reasons. It just means that the next couple of months are going to be filled with a lot of time on my computer, trying to get Java to compile and C++ to work.
Want fries with that?