http://www.mediafire.com/?08d650uxvksce6r (.jar file)
http://www.mediafire.com/?l94qb25bdvhz2q4 (.java file)
I decided to finally finish my little side project yesterday, “Last Slice Decider.” It was largely finished from the last time I worked on it, which was in August.
All I needed to do were three things: successfully loop through three names, write a method to save the loop to a file, and a method to load the file the next time the program is launched.
For my first task, I tinkered with several different loops before finding the best one. I decided to create a member integer variable named “order” and I set its value to 0. Then I created a method called “listPerson()” and created a switch statement with cases numbered 0-2. Each statement used the setText() method of JLabel to display a different name. After each statement, I wrote the brake statement to prevent the switch statement from fulfilling more than one case requirement. I wrote order++ outside the loop so the switch statement will always go to the next case the next time the method is called. Finally, I wrote an if-then statement that sets “order” to 0 if it’s value is equal to 3, successfully going back to the beginning of the loop.
After successfully creating my loop, I decided to look up the best way to load and save data to a file. I found a good tutorial on object serialization and decided to implement it in my program. I made all three password fields transient to prevent the passwords from being saved in the data file. The rest is pretty much self-explanatory. I wrote a method called “saveData()” that creates a file named “pizza.data” and an ObjectOutputStream. The writeObject() method of the ObjectOutputStream is then called and “order” is saved to the pizza.data file. This method is called every time the “listPerson()” method is called (ie, the user clicks the “Yes” button), after all of the switch and if-then statements are executed. Next, I made a method called “loadData()” which does the exact opposite. It loads the pizza.data file and inputs it into an ObjectInputStream, and casts “order” to an Integer object before being read from the file. This method is called at main, which ensures that the data is always up to date.
Don’t worry if you have no idea what the hell I just said, it’s a simple program with a relatively complex user interface. Just download the program and try it out. I know it has no use for you, but it has a lot of use for me. :P All three passwords are “t,” this was just a test when I was debugging my application. My brothers and I will have three completely different and (hopefully) complex passwords when we use this program. I have also included the source code with this post (everything is heavily commented) so feel free to poke around with it.
I’ve decided that my next project will be a text adventure game. I got the idea of making one yesterday, when I discovered how much fun I had playing the 1980 game Zork I. Text adventure games are a lost form of art; it really requires the player to use their full imagination to get the most out of the game. I learned that games don’t have to have graphics in order to be a challenging and fun game. This project will be a great opportunity for me to get more familiar with the process of creating games. I also won’t have to worry about dealing with graphics, which will make the project so much easier. The game will take place in a castle, with the outside area containing a pond that leads into an underground cave and a huge garden. There will be various items to collect in this castle containing witches, skeletons, ghosts, and creepy goons. I haven’t worked out the story yet, but I think the main character will be a nameless thief who thinks his big break will await him inside the castle. I’m thinking about including a genie lamp as the item required to beat the game. I’m also thinking about including multiple endings, with situations in which the player can die. This is going to be my biggest project yet; I don’t know when I’m going to start working on it, but it’ll probably be over the summer when I have more time to commit to Java. I’m going to draw out the map for the game and flesh out the story sometime soon. I also found a cool website that guides you through the process of making a text adventure game; I’m definitely going to use it as a reference for when I make my game. Please look forward to this game!
I should have posted my introduction sooner, but now is as good a time as ever. My name is Austin Guiney, a beginner programmer and actor. I’m 16 years old and in the 10th grade at the time of this writing. I began learning Java to acquaint myself with programming and gain experience so that I may eventually make my own independent video games. As mentioned earlier, I also act and help my brother make his weekly comedy sketches. I’ll be updating my blog with information on my current programming projects and perhaps some other interesting stuff.
Before I end this post, I want to give you a heads up on future projects:
Simpsons Sounds (Nelson Edition) - The same Simpsons Sounds application, only just Nelson! This will be closer to my original idea, and will feature Nelson Muntz’s signature “ha-ha” laugh in as many languages as possible. I originally ditched this idea because it is a pain in the ass the do.
Pizza Decider - I don’t know about your family, but ordering pizza is a huge deal in my family. This application will help you with the painful process of deciding what pizza to order. Features will include deciding how much money each person pays and how much one has to pay if they owe another person money.
I made this application using the Java programming language. It plays an array of sound clips from the “The Simpsons” by pressing any number between one and six.
This is my first real Java application. When I say real, I mean an application that wasn’t made for the sake of learning the language. Strangely, this project has been an idea for quite awhile. It was first suggested by my brother, since he has a huge liking to Nelson Muntz’s laugh. He wanted a program where you could play Nelson’s laugh by simply pressing a button. Since there wasn’t anything like it at the time, I promised him it would be the first thing I made in Java. I expanded upon his original idea, and decided to add five more Simpsons sound clips in addition to just Nelson’s laugh.
I’ve been working on this project for about a week, scraping in a little bit of time each day thanks to school work. It doesn’t seem like much, but I had originally planned for more. Among the things I ditched was a picture of Nelson Muntz before the explanation. Getting pictures to work is a pain in the ass and it wasn’t really worth the trouble. I’ll release another version of this program eventually, when I’m better at Java and have the free time.
I’m quite proud of myself for making this little program. I’ve taken a liking to programming, it’s quite fun. I’m still learning Java through a book I got for Christmas, and I intend to learn new languages such as C, C++, and Perl in the future.