Mobile Development Workshop
JAVA REFRESHER
Mobile Development Workshop JAVA REFRESHER Overview Programming - - PowerPoint PPT Presentation
Mobile Development Workshop JAVA REFRESHER Overview Programming languages Object Oriented Programming with Java First up Create a new project in Netbeans Call it Bank Running a Program Programming Languages High-level languages are
JAVA REFRESHER
Programming languages Object Oriented Programming with Java
Create a new project in Netbeans
High-level languages are relatively easy to use
Unfortunately, computer hardware does not understand high-level languages.
language.
The Java compiler does not translate a Java program into assembly language or machine language for a particular computer. Instead, it translates a Java program into byte-code.
Machine.
Java is an Object Oriented Language
Objects can have data and actions Data is stored in variables Actions are defined in methods
Objects of the same kind have the same type and belong to the same class.
data
The data and methods associated with any particular class are encapsulated (“put together in a capsule”), but only part of the contents is made accessible.
how the class works.
An automobile consists of several parts and pieces and is capable of doing many useful things.
important to the driver.
power steering pump is not important to the driver.
Create a new class called BankAccount Give it the following properties
Give it a constructor that takes an ownerName and starting balance to set up the object Project a getter and setter for the ownerName property
Create two new methods
Classes can be organized using inheritance. A class at lower levels inherits all the characteristics of classes above it in the hierarchy. At each level, classifications become more specialized by adding other characteristics. Higher classes are more inclusive; lower classes are less inclusive.
Create two new calsses
Both classes should inherit from the BankAccount class
Flow of control is the order in which a program performs actions. A branching statement chooses between two or more possible actions. A loop statement repeats an action until a stopping condition occurs.
A branching statement that chooses between two possible actions. Syntax
if (Boolean_Expression) Statement_1 else Statement_2
In the BankAccount class
equal to zero
When a subclass functionality from a base class, it can discard the functionality it doesn’t want by overriding the previous implementation The older version is still there, and can be accessed using the super keyword
Override the withdraw() method in your CheckingAccount class to allow overdrafts up to $100
Boolean expressions can be combined using the "and" (&&)
Example
if ((score > 0) && (score <= 100)) ...
Not allowed
if (0 < score <= 100)