Professional Documents
Culture Documents
Unit 1 Swift. Playground Class Presentataion
Unit 1 Swift. Playground Class Presentataion
Unit 1
Introduction to Programming
Building Blocks
Variables
Integer
Float
Boolean
Class
Object
Basic Building Blocks
Variables
Bank account balance, it shows the current amount of money you have
available. Your bank account may be $100 at the beginning of the month,
and $350 on your payday.
This is an example of a variable.
A variable is a representation of a value.
Variables come in many different shapes and sizes.
Different types of variables hold different types of values.
Numbers, letters, words, true, false, or even a custom car.
Integer
An integer is a whole number, a number without any decimal places,
positive or negative: Example -10, 0, 100, 21031
An integer could be used for the number of stars for a movie review, a
house’s street address, or the score for a sports team.
Basic Building Blocks
Float
need to be more precise with a value.
In the case of currency, a decimal place is used to keep track of the cents on a
dollar $10.51
A decimal-based variable is called a float. Float is short for floating point,
another name for a decimal place
Boolean
Respond with either Yes or No.
cannot respond with 7, $103.45, or “Banana.”
Yes or No variable is referred to as a Boolean.
Similar to a light switch—they are either on or off,true or false; there is no in-
between value
Basic Building Blocks
String
Name - collection of letters that form a set of words
Eg:"SteveDerico"
A string is used to represent characters strung together to make words
and sentences.
A string can hold a series of letters, numbers, and symbols. Strings are
surrounded by a pair of quotes. For example:
"Steve is cool."
"Where is the ball?"
"Go Giants
Basic Building Blocks
Classes
Different types of automobiles –different –few core
characteristics
wheels, an engine, and brakes
Core characteristics are called attributes.
purpose and provides value to the consumer.
A car can drive, honk, brake, and steer. Basic methods are
available in every car.
Without these methods, it would not be a car. These core methods
are called behaviors.
Designing a new car, a blueprint would be a good place to start.
Blueprint is a document that serves as a template for building
something. Blueprint defines the attributes and behaviors of the car
Basic Building Blocks
Car blueprint
Methods
computer processes a list of steps to achieve a task. This
list of steps is called a method.
A method is a collection of code to complete a specific
task
Example –Cooking Process
Basic Building Blocks
Car
Inheritance Wheels Standard
Engine Standard
passing down of attributes and behaviors from
Brakes Standard
parent to child is called inheritance. Can Drive Forward
Inheritance is the ability for a class to extend or Can Stop
override functionality from a parent class. Can Steer Left and Right
Example - class you created was the parent of SUV
the SUV class. Wheels Mud
SUV class will inherit all the attributes and Engine V8
behaviors of the car class. SUV will also be Brakes Standard
Drive System All-Wheel
able to add its own attributes and behaviors.
Can Drive Forward
Can Stop
Can Steer Left and Righ
Can Drive Uphill
Can Tow a Boat
Basic Building Blocks