Monday, April 27, 2015

Arrays

Arrays have many uses, however their main function is to store values in a list of multiple values. They can be lists of Characters, Integers, Floats, Strings, or really any other variable type, even other arrays. You can add change, and reset values within an array. Each valuein the array can be accessed by using arrayName[numberOfValue]. the number of the value is the spot the value is assigned to. each array has spots that are 0 through whatever the size of the array is. the size of the array is declared when the array is declared. For example: int Array[] = new int[10]. the bolded number is the size of the array. assigning a value to a spot in an array goes something like this: Array[4] = 24. this issigns the value 24 to the 4th spot in the array. Arrays can be used to do many things, such as make a progam the deals a set of cards, or a programming test called FizzBuzz.
This is a program I created to generate a random hand of cards based on a full single deck of 52 cards. Joker not included. The Array of Strings that trails off the screen is an array of every posssible card. The numGen method generates a random number that is not the same as any number previously generated.

This is the frist window that will pop up. It is a list of numbers 1 through 52. You chose what number of cards you want dealt to you.

These are the cards you recieve. The first letter or number is the type of card. For example, 3 is a three, J is a jack, A is an Ace. The second letter is the suit, for example, H is hearts and S is spades.


This is Everything about FizzBuzz. The description is in the top left corner. The code is in the box below the description, and the Box with all the green boxes inside is the tests ran on the program and the green indicates they resulted in the outcome required.

No comments:

Post a Comment