Thursday, March 26, 2015

Array Explanation

Here's some random things that I know about arrays.

An array is a "list" or groups of values, and can be in any type of value. [0] is the first index.

There are int[], String[], boolean[] arrays and many more.

You can declare a array in two ways:

int[] testArray;
or
int testArray[] = new int[5];

The second way will create an array with 5 empty values. You must declare an amount of values. the array cannot change size after it has been created.

testArray.length; // the length of the array

You can change a value using testArrat[n] where n is the index of the value you wish to change;

testArray[2] will return 6, for example.
testArray[2] = 4; it will now return 4.

You can't just print an array. However, you can iterate through an array like this:

for (int i: testArray) {
   System.out.println(i); // this will print every value inside of testArray on a new line.
}

To compare values, you would still abide by the normal procedures. If you have a String[] array, you'd use .equals, and == for mostly anything else.

These are some more topics that should have been learned:

  • To use arrays to store data in and retrieve data from lists and tables of values. 
To store, you'd put testArray[0] = 1; and to retrieve you'd put int variable = testArray[0].
  • Pass arrays to methods. 
To do this, you'd create a method that takes in an array. You can return arrays too, but you can't print them.

Thursday, March 5, 2015

Pig Latin Converter / Age Verifier

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, February 12, 2015

Java Chapter 5 (Extra-Strength Methods)

Important Concepts:

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.
Loops:
  • while (x > 4) This will continuously loops until the condition becomes untrue.
For loops:
  • for(int x = 10; x < 20; x += 1) Here, x will increase by 1 until x >= 20.
Random numbers:
  • import java.util.Random;
  • then later add:
  • int randomInt = randomGenerator.nextInt(100)
  • which will create a random number 0-99.
String > Int:
  • int x = Integer.parseInt("1234");
Int > String:
  • 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:

  • 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.
So, I created a little "comparison" between Python and Java for using iterations. Both programs find the the words in a list containing the letter "a". Here ya go:

Java:


Python:


As you'll notice, Python is so much simpler and easier to understand.


Thursday, January 29, 2015

Proof That I Am Competent


This makes sure you know who the real Great Leader is: John Randolph.

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
Something like 'train engineer' would be considered primitive. Here's a train engineer (for reference purposes):

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:

  • instance variables are the properties of an object.
  • methods are the things that an object does.
  • a class is similar to a java blueprint.
These are the 3 basic ideas in the code: instance variables, methods, and classes.

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.

Thursday, December 11, 2014

1.3.8 Guesser Thing






  1. If you change between 1 and 20 from the previous program to between 1 and 6000, how many guesses will you need to guarantee that you have the right answer? Explain.
You would need 6000 guesses, because you could guess 1 then 2 then 3, and if the correct number was 6000, you'd need 6000 guesses. I guess. 
  1. Describe the difference between a while loop and a for loop.

While will continue until a certain variable changes, and it can be affected mid-way through its run-time. A for loop will run a specific amount of time, and you can't change the amount of times it is run. 



Tuesday, December 9, 2014

1.3.7 Options


This was the code for the Lottery option. You had to input your ticket numbers, and it created the winning numbers. It gave you an output of the number of similar numbers.


This is the code for Hangman. Running hangman() will initiate it. It stops after the word is guessed. I stored the words as lists, not strings. So ['w','o','r','d'] not "word."


1. Sometimes code using an iterative loop can be written without a loop, simply repeating the iterated code over and over as separate lines in the program. Explain the disadvantages of developing a program this way.

This would make the code very long and repetitive, and would make it very difficult to change the iteration. 

2. Name a large collection across which you might iterate.

A list of words, like names or words in a text document, or if you were searching for a word in that document. You would want to iterate through it, it would be nearly impossible without iteration.

3.What is the relationship between iteration and the analysis of a large set of data?

To analyze a large set of data, you'd need to iterate through it to read each piece of data.



Friday, December 5, 2014

1.3.6 Guess a Letter


Conclusion 
1. Consider a string, tuple, and list of characters.
In []: a = 'acbde'
In []: b = ('a', 'b', 'c', 'd', 'e')
In []: c = ['a', 'b', 'c', 'd', 'e']
The values of a[3], b[3], and c[3] are all the same. In what ways are a, b, and c different? 
A string is just a word, letter, or sentence. A list/tuple can be the same thing but it's all divided into individual strings. Tuples are a fixed size, while lists are much more dynamic. You can't add or remove elements of a tuple, but you can with a list.
2.  Why do computer programming languages almost always have a variety of variable types? 
 They have a variety of types so that they can be more efficient under different circumstances. For example Boolean logic is very useful if you just need True or False, and not complicated numbers or sentences. Having integers and strings make math easier to do, especially if you want 5 to be '5' and not a number.
3.  Why can't everything be represented with an integer?
Because some things aren't integers? Floats aren't integers and neither are strings. Integers can be used in math, but it would fail if you tried to use integers as strings. 

Wednesday, December 3, 2014

1.3.5 Check Tweet Post





The comments are in the screenshot.

Conclusion Questions:
1.       How many characters are in this sentence? Does it matter whether Python is storing the string as one byte per character or four bytes per character?

The total characters is each letter, space, and symbol used in the sentence. Python would need to store it as 1 byte so that the length of "hi" isn't 8.

2.      This question asks you about something you have not learned. In fact, the question is asking about details that go beyond what you will learn in this course. However, wondering what is going on at a lower level of abstraction – and talking about it – can be a useful strategy when learning about computing.


Describe what you think occurs in memory when the following code is executed.

c would be "one" + " and " + "another", so it would be "one and another".
it would print 6-10 of c, so "d an".

It will remeber each letter's variable, and then combine parts (bytes) from each variable.


Friday, November 7, 2014

Broom Ball App


Reflection Questions:

1.  Reflect on the creative process you used. What was useful? Discuss your reflection with your partner and then write a reflection individually.

We created this app based on a preexisting issue. My brother asked me to make him a program for scoring a broom ball game, and so we built the app to work with the rules of the game. We need a score for each team, and shots for each team. Each game is 20 minutes long, so we added a timer to the app as well. We added the ability to pause and stop the time as well.

2.      Reflect on the team dynamic. What helped the team work well together? Discuss your reflection with your partner and then write a reflection individually.

We worked well together because I wanted control over the coding of the program. I was allowed to be independent in making it without the stress of having two people work on it. Tyler did help with some problem solving when I couldn't understand things. He helped with the design of the actual app so that it was aesthetically pleasing.

3.  What Problem was your APP attempting to solve?  How well does it?

The problem being solved was the need of an app to score a broom ball game. We solved this well, by adding an easy-to-use scoring system. We added +1 and -1 buttons near each teams score and shots to it could be easy to use. We also added images next to the timer so it was easy to understand how to play/pause and stop the timer. 

4.  Desribe the two hardest challenges you experienced when coding this app.  How did you overcome them.  Post a screen shot of these sections of code, and explain them.

1.




The main issue we ran in to was creating the timer. At first, we started with two different timers, timer() and seconds_timer(), one for minutes and one for seconds. We found that the two timers were slightly off, and the minutes would change 2 seconds early. To solve this, we made the minutes change based on the seconds, and when seconds reached 00, the seconds changed to 59 and the minutes changed to minutes-1. When minutes=00 and seconds=00, the timers ended. This caused the timers to work well.

2. The other issue we had was the display of the seconds on the app screen. For example, when it should have showed 10:08, it showed 10:8. So I added the purple sections of code to add a "0" before the seconds if seconds<10, and add nothing if seconds>=10. This made the time display correctly.

5.  Given more time how could you improve your game

If given more time, we would have added the ability to manually change the amount of time on the timer, however it wasn't necessary. All broom ball games are 20 minutes long, so it wasn't absolutely needed. It would have been nice to add, though.

APK File:

https://drive.google.com/file/d/0ByMTTfD-NNaJZnFTM29KZUhpblk/view?usp=sharing

Thursday, October 16, 2014

Blown To Bits

Blown to Bits Assignment:

1) The change towards a digital world is inevitable and will transform the way normal people go about their daily lives.

2)    a. Define what a "bit" is.
       b. Determine some advantages of the use of "bits" for safety purposes.
       c. Elaborate on how communication companies like Verizon or AT&T could restrict freedom of              speech?
       d. Describe Moore's Law.
3)  I agree that computing will transform society. In fact, I think it could be argued that computing has already transformed our society. People use smartphones and websites every single day, and it often affect our personal lives. Many people's jobs would not exist without computers. People find news and information online, and many print sources are becoming deprecated.



Tyler Culmo's Questions:
1) Clarify what makes a "bit"
   - A "bit" is a piece of information made of 0's and 1's that are stored on computers.
2) Compare physical and digital processes needed to accomplish a task
   - Digital processes are typically faster than physical ones, and it involves less work.
3) State how you feel about the idea of things such as SSN, Medical Information and birth records stored forever unless there are policies to get rid of it.
   - I think it's a dangerous situation as far as privacy is concerned. It needs to be governed better and have more restrictions. 
4) Determine whether or not the rapidly advancing technology is good for the humans.
   - I  think it's good for humans, because it'll make us more advanced and allow us to perform various tasks more quickly.

Monday, October 6, 2014

Poke-cave Game





Throughout the project, our group was successful is working together to complete the various tasks that were required to finish the game. Many things required some very complicated coding, such as the curtains following each other and the wall sprites over the background. We didn't have enough time to finish everything, like the music and more levels. I learned how to better use photoshop to make anti-aliasing not happen. I also learned how variables in Scratch works, and I learned how the broadcasting works. We worked just like best friends, and now we're best friends FOREVER.