Create your own polished presentation in minutes. Just describe what you need.
Free to try, no credit card requiredHomework
github.com/colabug/Penguin-Java-Example
1. Fork repository locally
2. Read HOMEWORK file
3. Complete exercises
4. Commit and push to github
Code
Object oriented language
Compiler
Compile once, run anywhere
Java
Program
(Executable)
Big words, easy concept!
Basics
Application Programming Interface (API)
Operators
Variables
assignment
math
No reserved words
Begin with letter
int weight = 25;
camelCase4LongNames
Name
Value
Type
relational
logic
Types
Array
Examples
Primitive
short
boolean
float
String[] daysOfWeek = new String[7];
daysOfWeek[0] = "Sunday";
daysOfWeek[1] = "Monday";
daysOfWeek[2] = "Tuesday";
daysOfWeek[3] = "Wednesday";
daysOfWeek[4] = "Thursday";
daysOfWeek[5] = "Friday";
daysOfWeek[6] = "Saturday";
int
// Primitive & string
boolean isHungry = false;
float pi = 3.14159;
char q = 'q';
String teacherName = "Corey";
// Objects
Penguin babyTux = new Penguin();
Object object;
double
char
long
Object
String
x = 10
x = 2 * x + y;
Activity!
x = 6
x += 2;
z = (x <= y);
z = false
int x = 4;
int y = 2;
boolean z = false;
z = true
z = (x == 4);
Objects in code
Control Flow
Activity!
Turn a recipe
into a method.
ingredients / input / parameters
Ingredients
public Sauce makeSauce( Strawberries strawberries, Sugar sugar )
{
// Process strawberries
strawberries.clean();
strawberries.chop();
// Make sauce
sauce = strawberries.coverWithSugar();
sauce.refrigerate();
// Return sauce
return sauce;
}
Instructions
Clean & chop strawberries
Recipe steps
Cover with sugar
Class
Put in fridge
Finished product
Corey Latislaw
Method
¶
Related statements
name
keyword
Test a condition
Loop
access modifier
keyword
inheritance
if
while
Example: If the penguin is hungry, feed it fish. Otherwise, make it swim.
Parameters
Return type
Name
Access modifier
public class MathFunc
extends Funcs
{
int squared( int x )
{ return x * x; }
}
Example: While the penguin is hungry, feed it fish (stop when it is full).
public int square( int x )
{
int squared = x * x;
return squared;
}
Method
if (penguin.isHungry())
{
penguin.eat("fish");
}
else
{
penguin.swim();
}
Return statement
while (penguin.isHungry())
{
penguin.eat("fish");
}
Conditional loop
Scope
Access
for
Example: Feed the penguin 7 tires.
Global
public
Class
private
Local
protected
for (int i = 1; i <= 7; i++)
{
penguin.eat(tires);
}
Object Oriented
Defining a complex system in terms of objects.
System
Set of related objects.
Object
Item or concept with
attributes and abilities.
Inheritance
Penguin
Children inherit parent
state and functions.
Age
Attributes?
Example:
Penguin is an Animal.
Animals have a height and weight, so a Penguin does too. Penguins can waddle, but not every Animal can.
Eye
Abilities?
Beak
Animal
Weight
Hungry?
age
weight
is a
= inheritance
Penguin
Good Practice
leftEye
rightEye
leftFoot
rightFoot
beak
Foot
waddle()
swim()
eat(fish)
has a
has a
Hide attributes, but advertize abilities.
(information hiding)
has a
Foot
Eye
Beak
composition
DSLR
currentLens
saveToSDCard()
changeLens()
Activity!
is a
Camera
lens
eyePiece
shutter
takePhoto()
adjustLight()
adjustZoom()
has a
has a
has a
Describe a camera in terms of objects.
Lens
Eye piece
Shutter
2011
Android
Widgets
Notifications
Voice actions
Multi-tasking
Source: android.com/about
Intro
Who are you?
What are your passions?
What do you want to learn?
Corey
@androidphilly
Android Alliance
Rules
This is a safe space.
There are no stupid questions.
Learning is the objective.
Everyone finishes together.
Goals
My Goal: Android Army
http://www.technesstivity.com/wp-content/uploads/2011/06/Androids_are_coming.jpg
Make your first Android app.
Leave with a desire to learn more.
CoreyLatislaw.com
XfinityTV
Philly ETE
WXPN
HowAboutWe
assignment
=
+=
/=
++
increment
modify & assign
*=
%=
decrement
--
-=
@corey_latislaw
Android
Corey Leigh Latislaw
http://coreylatislaw.com/android-101-class-1/
-32,768
32,767
-2,147,483,648
2,147,483,647
-9,223,372,036,854,775,808
9,223,372,036,854,775,807
1.40129846432481707e-45 3.40282346638528860e+38
4.94065645841246544e-324d 1.79769313486231570e+308d
// Begin class body
// End class body
waddle()
swim()
eat(item)
<3
addition
multiplication
+
concatenation
*
positive
/
division
subtraction
-
%
remainder
negative
!
||
&&
and
not
or
>
>=
==
greater than
greater than or equal
equal to
<
<=
!=
not equal
less than or equal
less than
IntelliJ
IDE - Integrated Development Environment
Assignment
Make sure the condition terminates!
A-Z
underscore
a-z
0-9
authenticate(username, pass)
getToken()
dev.twitter.com/docs/api
// Begin method body
// End method body
Create your own polished presentation in minutes. Just describe what you need.
Free to try, no credit card required