Thursday, January 22, 2015

Aaron's Java Blag 5: In which I make something actually useful



Today I made a program that might actually be useful! Shocking, I know.

The program I made will MLA cite a website for you if you give it all the information it needs. It also happened to use a lot of things I’ve learned for other programs (such as if statements and scanners) plus a few new things, so I thought it’d be nice for this final post.

The first thing that you might not recognize are the strings. Although I’ve been using them, I was mostly just copying what the book told me to do until now because I wasn’t quite sure what type of data they were, so I didn’t talk about them. According to the book, they are technically objects, but can act somewhat like primitives (Bryant The Special Type: String). That means although they aren’t one of the three types of primitive data I’ve been using since the second post, they’ll act similar in some ways, such as defining them in the same way (String name = “string”) and adding them together (just use stringname + otherstring to put them together, like adding two numbers). However, they do have a few differences, which I needed to understand in order to use them effectively.

The main difference is how I can use them in if statements or loops. With primitive data such as ints you would just need to do if (myInt == 2), but that won’t work for a String. I looked it up in the book, and it said that “To compare objects (including instances of the String class), Java programmers use the equals method. Any object whose instances can be compared to each other should implement the equals method (which is defined in the Object class)” (Bryant Operators). The equals method is the equivalent to using the == for primitive data, and it is written as string.equals("string that you want to check for"). I used string.equalsIgnoreCase() in this program, which is the same thing but ignores capitalization.

Another thing I learned was the null data. The book had a long explanation on null data, but in summary it just said that null data is essentially “empty” data (Bryant The Non-Existent Type). I set any information that the user can’t provide to this so that it doesn’t just put the word “none” in their citation.

With all that said, I think I’ve explained how this works well enough. Here’s what the program ended up looking like:

It’s a bit long, since there were multiple strings I needed to define. I decided to cite this blog post as a test of how it works. Here it is:


Pretty cool, huh? I came into this barely knowing any programming, and now I can make programs to help me in school. I’ve had fun using all these programs, and even the process of making them has been fun. That being said, here’s my final Surprisingly Insightful and Thought-Provoking QuestionTM:

Which do you enjoy more: The excitement of working on a project, or the satisfaction after its completion?

I’ve found that for a project that is related to something I enjoy doing, I enjoy the process of creating it more than the accomplishment afterward. I suppose it’s like reading a good book in that regard- once it’s over I just don’t want it to end, no matter how good the ending was.

What do you think?

Bryant, Jay. Java 7 for Absolute Beginners. Berkeley, CA: Apress, 2012. Books 24/7. Web. 22 Jan. 2015.

7 comments:

  1. Aaron: This was awesome! It's so cool to see you making programs to help with school. I despise citing things in MLA, so I always use easybib or a citation machine. I'm sure your program will prove to be useful in the future. As for your question, I enjoy the satisfaction after the project is complete. Usually, I have no motivation to work on a project, but once I finish it I enjoy the satisfaction of checking it off my never-ending list of stuff to do.

    ReplyDelete
    Replies
    1. Thanks Angel! Making these programs based on things I'm doing in school has been fun, even though they probably won't really be that helpful.

      When I posed that question I was thinking more about things I like to do, but it seems like you applied it to things like school projects, in which case I'd probably agree with you since I don't enjoy working on those. The kinds of projects I like working on are ones where I can do them on my own time.

      Anyway, thanks for reading!

      Delete
  2. Just a quick questions. one is that for other things sometimes if a slot is left blank you want it to say something. (not just leave it blank, like say NA) it is possible to do this? (or at least from what you know)
    Don't get me wrong this is amazing, just hoping to help keep improving

    ReplyDelete
    Replies
    1. Thanks for reading, Kyle!

      Yeah, it's pretty easy to have it say something else, I would just change null to "whatever I want it to say instead" and it would just print that. Right now it's set up to just null things if you say "none" because I wasn't really thinking about that when I wrote the code and I wanted to show off the null.

      Theoretically, with what I know right I could make it exactly like Easybib (except for the part where it finds information for you and the part where it italicizes things), but that would take a while. Thanks for the advice, anyway. Maybe I'll go change it later.

      Delete
  3. Aaron, I thought it is so cool how you can do this in high school. I thought this was a really cool blog because you can show people how to do this programing that most people don't even know exist. I feel like this will take you far in the future.

    ReplyDelete
    Replies
    1. Thanks, Molly! Hopefully I'll be able to continue learning Java and making programs far into the future, whether it's as a job or a hobby.

      I've actually thought a but about what to do with this knowledge in the future. Our high school is actually one of the most likely to find people able to do this kind of stuff, as we have a few Java classes. I might take one of those, and then if I'm able to get good enough I'll see if I can start helping program the robot in the Robotics Club. I might even choose something like that as my career. I hope you got to learn something that you'll be able to use far in your future, too!

      Delete
  4. Hey Aaron, its nice to see you working on java (robotics maybe?) To answer your question I'm a completion and I enjoy finishing things so I like the satisfaction of a complete project more than working on it. Hopefully you can take this java coding somewhere useful in the future.

    ReplyDelete