Since Chapter three was dedicated to making sure you knew what variables are, I decided that I would make a code that uses several class variables, involving strings and integers. Here is the code:
The code is designed to loop 5 times untill a grumpy farmer gets sick of hearing his dogs bark! after that he gets fed up and yells for them to be quiet! He needs some earplugs!
Friday, January 30, 2015
Thursday, January 22, 2015
Chapter 3: Variables (Fixed)
(above is the result of compiling the dog code)
Fundementals of Variables in Java:
- There are several variable types in Java:
Float
Int
Double
Bool
Byte
Short
Long
Char
- Float's use decimal values (ex: .25, .111, .8)
- Int or Intiger uses full number values (ex: 1, 5, 25)
- Doubles combine BOTH Float and Int values (ex: 1.25, 3.49, 6.64)
- Bool or Boolean Variables use either True OR False (ex: While True, do this...)
- Byte variables are 8-Bit variables, used to save memory in large arrays (ex: byte a = 100 , byte b = -50)
- Small variables are 16-Bit and used to help conserve data. Its Minimum and Max value are -32,768, and 32,768
- Long variables are 64-Bit and are also used to conserve data. Its minimum and Max values are - 2,147,483,648 and 2,147,483,648
- A char variable is a variable that uses a charector (ex. A, B, C, D)
Thursday, January 15, 2015
Chapter Two: A Trip to Objectville
This chapter really emphesized Javas features as an object oriented programming language. Most of the reading was a story about two programmers assigned to accomplish a task. One programmer prefered to use procedureal based program, and the other liked OO. In the end the OO programmer had the advantage because he had the ability to program without having to touch a single piece of previously tested code, whereas a procedural programmer would have to rewrite the whole code to accomidate for the new specifications.
Later on you also begin to read that all of Java code is defined as a class. One analogy that the book made to the setup is that a Class is to and Object, as a Recipee is to a Cookie. Objects can store information, and also execute tasks. Things objects know about themselves are known as instance variables. These variables represent the status of an object. Like functions in Python, things objects do are called Methods. Different classes can inherit conditions from other ones.
Friday, January 9, 2015
Headfirst Java: Chapter One
Reading chapter 1 of the book, Headfirst Java, has taught me much about the setup and structure of Java programming. Compared to Python, Java is organized much differently. Java is setup in the sequence of Source Files; within those files there are class files, and again within those class files there are Methods, and within methods there are statements.
Python, is very different in the organization. In python there are the Source files, and class files. The difference is in the class files, is that they aren't organized in methods. There are loops, and functions. Loops only active while the code is being read, and functions only activate when typed into the command prompt. Within either loops or functions, there are also statements, however the syntax also tends to be much shorter than Java's.
For example, to get a program to state a string, all you need to do is use the statement: print "Your statement here". In java you have to use the statement: system.out.print "Your statement here." Below is a snip-it of the code I worked on to help get to learn the syntax and structure.
Python, is very different in the organization. In python there are the Source files, and class files. The difference is in the class files, is that they aren't organized in methods. There are loops, and functions. Loops only active while the code is being read, and functions only activate when typed into the command prompt. Within either loops or functions, there are also statements, however the syntax also tends to be much shorter than Java's.
For example, to get a program to state a string, all you need to do is use the statement: print "Your statement here". In java you have to use the statement: system.out.print "Your statement here." Below is a snip-it of the code I worked on to help get to learn the syntax and structure.
Subscribe to:
Posts (Atom)