Rather than give some kind of long-winded explanation of why I'm doing 100 days of coding, I'll provide a short summary that is, essentially, why I imagine most people do it: I want to get better at coding. I code at work, and I code at school, but often, those can feel repetitive, and don't always expand my skillset. I'm going to try to find interesting projects to undertake on days that I am not doing school work, and hopefully become a better coder.
With that said, this first day of coding (actually two days ago, about 28 hours) is school work. I take a programming course from a nationally accredited school, because I have aspirations of gaining a masters one day, and credited programming courses can help with that. This course uses Java, which I am only familiar with through AP Computer Science (which I completely and utterly BSed my way through). With all of that said, this course (the second programming one I've taken from this institution) is going nice and slowly.
The second assignment for the class required us to write a program as follows:
import javax.swing.JOptionPane;
public class Quiz {
public static void main(String[] args) {
// TODO Auto-generated method stub
String question = "What is the capital of Texas?\n";
question += "A. Trenton\n";
question += "B. D.C.\n";
question += "C. Austin\n";
question += "D. Wyoming\n";
question += "E. Las Vegas\n";
while(true) {
String answer = JOptionPane.showInputDialog(question);
answer = answer.toUpperCase();
if (answer.equals("C")) {
JOptionPane.showMessageDialog(null,"Correct!");
break;
} else if (answer.equals("A") || answer.equals("B") || answer.equals("D") ||
answer.equals("E")) {
JOptionPane.showMessageDialog(null,"Incorrect, please try again.");
} else {
JOptionPane.showMessageDialog(null,"Invalid answer. Please enter A, B, C, D, or E.");
}
}
}
}
The code is largely self explanatory, asking the user a question, and then accepting an input. If the input is the correct answer, the program ends. If it's an incorrect answer, the program continues to ask the same question. If the user inputs something besides one of the options, it prompts the user to put a real answer.
As someone who works with Javascript and PHP daily, none of this is confusing per se. The ideas surrounding loops, inputs, and so on are familiar. The most alien parts are the parts that are essentially already filled out; whether a class is public, or has a return value, or is the main method. I understand all of these on a base level, but the mentality behind knowing which to use when building a new function is foreign to me. And I don't think that doing these simple exercises will help with that for a while. Still, though, it's good to be reminded that programming skills from one language do generally carry over to another; this assignment was essentially child's play.
Not a terribly interesting first post, but I'm not terribly surprised or upset by that. Tomorrow, I'll be sharing some of the Ludum Dare coding that I did yesterday (about four hours ago), which should hopefully be significantly better. And beyond that, who knows? 100 days. I'll do my best to stick to it.
Top comments (0)