01 intro to using java

17
Problem Solving with OOP and JAVA Problem Solving with OOP Welcome To and JAVA

Upload: program-in-interdisciplinary-computing

Post on 26-Dec-2014

1.078 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: 01 intro to using java

Problem Solvingwith OOPand JAVA

Problem Solving

with OOP

Welcome To

and JAVA

Page 2: 01 intro to using java

Meet Your InstructorThat’s me

Page 3: 01 intro to using java

Meet Your TA

IDC3931 © PIC

Alisha

Page 4: 01 intro to using java

Who Should Drink JAVA?

Have you done some programming?

Do you want to learn Java?

Do you prefer stimulating dinner conversations over coffee to dry, dull, technical lectures?

Do you need this course to graduate?Muahahahah

aha!

IDC3931 © PIC

Page 5: 01 intro to using java

Who Drinks JAVA?

IDC3931 © PIC

Page 6: 01 intro to using java

IDC3931 © PIC

What Is A Computer?

A computer is something that takes in information (input), processes it according to a set of instructions (program), and produces a result (output).

Computers communicate through a binary alphabet. The letters in this alphabet are ‘0’ and ‘1’. Everything else is made out of these ‘letters’ which are called bits.

Bits are represented in a computer by electrical signals: low voltage would mean a ‘0’ and higher voltage a ‘1’. Eight bits gathered together form one byte.

Page 7: 01 intro to using java

IDC3931 © PIC

What Is JAVA?Java is a free, open-source, Object Oriented Programming (OOP) language – everything is contained inside classes and objects.

Java is über portable – it can run on any machine with a Java Virtual Machine (JVM) installed.

No matter what computer you have, you can write the same Java programs.

Page 9: 01 intro to using java

Source Code

Compiler

Java bytecode

Virtual Machines

IDC3931 © PIC

How WE use Java

Page 10: 01 intro to using java

source code

class file

Code Structure in Java

method 1statement

method 2statementstatement

Page 11: 01 intro to using java

What goes in the source file?

A source file (with the .java extension) holds one class definition. The class represents a piece of your program, although a very tiny application might need just a single class. The class must go within a pair of

curly braces

public class Bicycle {

}

class

The source file MUST have the same name as the class. For example, the Bicycle class my be stored in the Bicycle.java file.

A class is the blueprint from which individual objects are created. Think of a bicycle…

Page 12: 01 intro to using java

What goes in a class?A class has one or more methods. In the Bicycle class, the pedal method will hold instructions for how the Bicycle should pedal. Your methods must be declared inside a class (in other words, within the

curly braces

public class Bicycle{

void pedal( ) {

}}

method

of the class).

A bicycle might have some methods such as: speedup(), break(), gear(), direction()…

Page 13: 01 intro to using java

What goes in a

method?Within the

curly braces public class Dog {void bark ( )

{

statement1;

statement2;

statement3;

}}statements

of a method, write your instructions for how that method should be performed. Method code is basically a set of statements, and for now you can think of a function or procedure.

public class Bicycle{

void pedal( ) {

}}

statement1;statement2;statement3;

What are you staring at?

Page 14: 01 intro to using java

One Blueprint Can Be Used To Help Build Different

Objects

Shape

rotate ( )playSound ( )

Square Triang

le

Circle Amoeba

This is called inheritance

Page 15: 01 intro to using java

EVERYTHINGis made from OBJECTS

Shape

rotate()playSound()

Object

equals()getClass()hashCode()toString()

Circle

doSomething()

This is the Object class from which ALL other objects are created.

Page 16: 01 intro to using java

What You Will Get Out Of Learning and Using

JAVA!A thorough understanding of Object Oriented Programming.

Learn a language that can be run on any platform.

Build your programming skills and confidence.

Learn how to work and program in groups.

Develop Graphical User Interfaces.

If you can make it through the day without programming, you haven’t triedJAVA!

Page 17: 01 intro to using java

Where To Start

Setup Eclipse Classic 3.6

Write your first Java program

Bring your laptops to class every lecture starting next week!