Showing posts with label ITC115. Show all posts
Showing posts with label ITC115. Show all posts

Thursday, March 20, 2014

Java Fail on Old Mac

While working on the last assignment for my Java class, a Hangman game, I got the following error on this bit of code:

switch(menuText)
{
case "new game":
resetGame();
break;
case "quit":
//quit, how?
break;
default:
//it has to be a letter
revealLetters(menuText);
break;

}

Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum variables are permitted

Unfortunately, the suggested fix broke EVERYTHING. 

A little reading on Java's website revealed this:

        Mac OS X Version 10.6 and below
Use Software Update available on the Apple menu to check that you have the most up-to-date version of Java 6 for your Mac. Java 7 is not supported by these older versions of Mac OS X. If you have problems with Java 6, contact Apple Technical Support. Java.com does not provide a download for these systems.
Indeed I have OS X 10.6.8 and can't upgrade my old Mini any farther. I guess I'm headed off to school early today to finish up in the computer lab.

Friday, March 7, 2014

Java

I feel very schizophrenic about Java. Whenever I turn in a completed working assignment I feel great, like I'm da man, and I know more than everyone. Then in class, we'll be asked to do something simple, and I have no idea how to. Up and down. Up and down. I don't feel like that in other classes, maybe because they hold our hand more. Maybe also, I need time to think and ponder and stew, but in Java class we're asked to write some Java right now. That's hard for me.

Wednesday, February 26, 2014

Bug Simulation

I worked on the Bug Simulation in Java a lot this last week. I was also sick. :( Logan came over and taught me a few critical things that made a huge difference in my ability to program it:

  • my understanding of how 'this' works
  • realizing that we were really dealing with POINTERS to arrays in Java
  • thinking of classes as INSTANCES of an object, not just a generic version of one

After these concepts settled in, programming from there was quick and painless!

Wednesday, January 29, 2014

Breakout2

I worked on Breakout2 for maybe 6 hours yesterday and today. I'm fairly pleased how it turned out, but I worry it could have been tighter. It works!

Monday, January 20, 2014

Breakout Blocks

I spent about 3 hours on Saturday working on a Java program to set up a breakout game. The programming went really smoothly. I'm really liking Java. I'm especially proud of this little bit of code inside nested for loops, though I'm not sure that it's good code:

//Decide fill color based on position
brick.setFillColor(Color.RED); //We know the first two rows should be this color, so no need to check which row right away. Also, this makes it default back to red if more rows are added later or something goes wrong.


if(rows == 2 || rows == 3) brick.setFillColor(Color.ORANGE);
if(rows == 4 || rows == 5) brick.setFillColor(Color.YELLOW);
if(rows == 6 || rows == 7) brick.setFillColor(Color.GREEN);
if(rows == 8 || rows == 9) brick.setFillColor(Color.CYAN);

On the one hand, there's no reason to check if rows is between 0 and 1 because that's where it starts so we can just assign it. On the other hand, it means for everything else it gets assigned twice. Which is cheaper, if statements like this or assignment?