Here they are:
Pig Latin Converter
The Age Verifier
I made the Pig Latin one able to be converted with sentences or words, and it also checks to make sure there's only letters inputted.
All of the pig latin "rules" are followed.
Thursday, March 5, 2015
Thursday, February 12, 2015
Java Chapter 5 (Extra-Strength Methods)
Important Concepts:
Operators:
BattleShip Project:
Here's some proof that I completed the BattleShip projects. The first screenshot is the different files needed to compile, and the second screenshot is proof that it executes.
One issue with this is that if you simply typed "3" three times, you'd technically get 3 hits, and you'd win. So as long as you find one hit, you can win. You'd solve this by adding code that would prevent you from typing the same number twice.
Operators:
- "x = 4" Sets the value of x to 4.
- "if (x == 4)" Checks to see if value of x is 4 (returns True/False).
- "<; >; <=, >=" Compares x to something else. Less than etc.
- while (x > 4) This will continuously loops until the condition becomes untrue.
- for(int x = 10; x < 20; x += 1) Here, x will increase by 1 until x >= 20.
- import java.util.Random;
- then later add:
- int randomInt = randomGenerator.nextInt(100)
- which will create a random number 0-99.
- int x = Integer.parseInt("1234");
- int integer = 42; String string = integer + "";
BattleShip Project:
Here's some proof that I completed the BattleShip projects. The first screenshot is the different files needed to compile, and the second screenshot is proof that it executes.
One issue with this is that if you simply typed "3" three times, you'd technically get 3 hits, and you'd win. So as long as you find one hit, you can win. You'd solve this by adding code that would prevent you from typing the same number twice.
Wednesday, February 4, 2015
Java Chapter 4
This chapter focused on several topics, including parameters, arguments, and operators.
The '=' sign is important in Java, and x = y is used when you're changing the value of x to the value of y. You'd use x == y when you're comparing the value of the two variables (must be primitive variables). For instance, you'd use:
if (x == y) {
x += 1;
}
If you want to see if two things are UNequal, you'd use != such as in:
if (x != y) {
x -= 1;
}
Any interesting thing, however, is when you try to compare Strings. you must use .equals(). For example:
String var = "Jose";
if ("Jose".equals(var)) {
var = "Joes";
}
Here's a personal example of how .equals() is used, as well as "==":
If you don't know what's going on here, I'm comparing a string in a list (names) to the variable "search."
The following are some of the important ideas from this chapter:
Java:
Python:
As you'll notice, Python is so much simpler and easier to understand.
The '=' sign is important in Java, and x = y is used when you're changing the value of x to the value of y. You'd use x == y when you're comparing the value of the two variables (must be primitive variables). For instance, you'd use:
if (x == y) {
x += 1;
}
If you want to see if two things are UNequal, you'd use != such as in:
if (x != y) {
x -= 1;
}
Any interesting thing, however, is when you try to compare Strings. you must use .equals(). For example:
String var = "Jose";
if ("Jose".equals(var)) {
var = "Joes";
}
Here's a personal example of how .equals() is used, as well as "==":
If you don't know what's going on here, I'm comparing a string in a list (names) to the variable "search."
The following are some of the important ideas from this chapter:
- Methods can have parameters, such as setTeamScore(team, score) has the team and score parameters. You could say setTeamScore(home, 45).
- Methods can accept literal values like "3" or 3, but can also take variables like glove or baseball, if glove = "glove" and baseball = 3, for example.
- If a method is declared as boolean, it must return a boolean answer. You'd call it "void" if it didn't need a response.
Java:
Python:
As you'll notice, Python is so much simpler and easier to understand.
Thursday, January 29, 2015
Wednesday, January 21, 2015
Dog Naming Barking Thing (chp. 3)
So, I made the Dog() thing. I added the eat() and chaseCat() classes, so those work as well. I prints as it should. I didn't implement the eat and chaseCat because I didn't feel the urge to. I cut off the "package" line, sorry about that. I know how important it is. This is pretty straight forward stuff.
Here's the Code Magnet thing about islands:
Some things I learned:
- primitive variable: byte x = 3;
- reference variable: Cat newCat = new Cat();
- primitive is anything like: 5, 'g', true, 3.45
Friday, January 16, 2015
Trip to Objectville
Throughout this chapter, I learned more about Java coding, and I specifically learned about methods, classes and instance variables.
I also learned about classes, which aren't used in Python. I know how how to make a new object using class var = new class(). I hadn't realized how it worked before, but now I know how it works. I got them to work, and it makes sense. I still think that Python is easier, but I now know how it works in Java. I still prefer Python.
Here's some things I learned:
I also learned about classes, which aren't used in Python. I know how how to make a new object using class var = new class(). I hadn't realized how it worked before, but now I know how it works. I got them to work, and it makes sense. I still think that Python is easier, but I now know how it works in Java. I still prefer Python.
Here's some things I learned:
- instance variables are the properties of an object.
- methods are the things that an object does.
- a class is similar to a java blueprint.
Monday, January 12, 2015
Breaking the Surface: Quick Dip
This is the Beer Song code. It has been fixed by forcing prints with beerNum > 1, beerNum == 1, and beerNum == 0. This way, it'll print "bottle," not "bottles." When run, it works as it should, obviously.
This is the PhraseOMatic code. The word lists are actually much longer, but they're cut off. It's very basic, man. It gives wonderful responses like: "What we need is a critical-path targeted vision" and "What we need is a 30,000 foot centric vision."
Java is a little different than Python. It uses ";" at the end of each line, and it's generally more "complicated." It uses a more complicated class system, and the "static/void/public" stuff that Python doesn't use. Python's "print" is less confusing that Java's "System.out.lnprint()." Both use basic things like strings, and integers, but Java makes it easier to mess up by making you write "String" (capitalized) while Python uses "str." Lists are also much easier to use in Python.
Subscribe to:
Posts (Atom)
