INT2104 - PowerPoint PPT Presentation

1 / 102
About This Presentation
Title:

INT2104

Description:

INT2104 (Object Oriented Programming Development) www.thawatchai.net/int2104 – PowerPoint PPT presentation

Number of Views:91
Avg rating:3.0/5.0
Slides: 103
Provided by: csSsruAc
Category:

less

Transcript and Presenter's Notes

Title: INT2104


1
INT2104 ???????????????????????? (Object
Oriented Programming Development)
www.thawatchai.net/int2104
????????? ????????????
2
?????????
  • ???????????????????????????( Introduction to
    Object-oriented ) ????????????????????????????????
    ??? ?????????????(object)????(class)?????????(Meth
    od)
  • ???????????????????????????? ???????????????? ?

3
?????????
  • ????????????????????? ??????????????????????? (
    Control Structures)??????????? ????????????????
    ????? (String) ?????? (Array)
  • ???????????????????????????????????
    ?????????????????? ??????????????????????(Polymorp
    hism) ???????????????????????????????????????(MySQ
    L)?????????

4
???????????
  • ????????????
  • ???????????????? ????????? ????? ?????????
    ????????????????????????????????????(
    Introduction to Object-oriented )
    ???????????????????????????????????
    ?????????????(object) ????(class)
    ?????????(Method) ????????????????????????????????
    ? ????????????????????? ?????????????

5
????????????
  • ???????????????????????????????????? (Object
    Programming with Java)
  • ??????????????????????? ??????????????????????????
    ?? ???????????????? ? ?????????????????????
    ??????????????????????? (Control Structures)

6
????????????
  • ??????????? ???????????????? ???????????????????
    (String)????????? (Array) ????????????????????????
    ??????????? ??????????????????
  • ??????????????????????(Polymorphism) ????????
    package???????????????????????????????????????????
    ??(MySQL)?????????

7
??????????????
  • ??????????????????????????????????????
  • ????????
  • Objects First with Java David Barnes Michael
    Kolling 2009
  • ???????????? JAVA ????????? ????????????? 2
  • ???????/??? ??????? ???????? ??????,2550
  • 2.Computing Concepts with Java Essentials 3rd,Cay
    Horstmann _at_John Wiley Sons,Inc ISBN
    0-471-24371-x

8
??????????? (???)
  • ????????????????????
  • 1.???????????? JAVA ????????? ????????????? 2
  • ???????/??? ??????? ???????? ??????,2550
  • 2 .???????????????????????????????????????? JAVA
    (????????????)
  • ???????/??? ??????? ?????? ? ??????
  • 3.Java GUI using NetBeans ??????? ????????
    ??????,2551
  • 4.????????????????????????? ??????????????????????
    ?????????????? ?.????????? ???????????? 2551

9
????????????????????
  • ????????????????????
  • 1.???????????? JAVA ?????????
    ????????????? 2
  • ???????/??? ??????? ???????? ??????,2552
  • 2 .???????????????????????????????????????? JAVA
    (????????????)
  • ???????/??? ??????? ?????? ? ??????
  • 4.Java GUI using NetBeans ??????? ????????
    ??????,2553
  • 5.????????????????????????? ?????????????????????
    ??????????????? .????????? ???????????? 2554
  • 6.http//www.thawatchai.net/int2104.

10
????????????????????????
  • ??????? ?????????? 5 ?????? 5 ?????????
    15 ????? ?????? 0
  • Midterm ??????????
    30 ?????
  • ???-??????????

    20 ????? ?????????
  • ?????????

    5 ?????
  • Final
    30 ?????
  • ???
    100 ?????

11
????? Java
???????? 1
  • ?????????????????, ????????? "write once, run
    anywhere"
  • ???????????????? Java
  • ???????????????????
  • Java ??? World Wide Web
  • ???????????????????

12
Object Oriented Technology Concepts
13
Object
  • ??????????????????????????????????????????????????
    ???????????? ?????????????????????????????????????
    ?????????????
  • ?????????? ???? ?????????????????????????
    ??????????????????????????????????????????????
    ?????, ??????, ????, ???????, ???? ???

14
Object
  • ??????????????????????????? ?????????????????,
    ?????????????????, ?????????????????? ???????
  • ?????????????????????????????????,
    ??????????????????????????????????????????????

15
Object
  • ????????????????????????????????????????
    ??????????????
  • ?????????(Attribute)?????????????
    ??????????????????????????????????????

16
Object
  • ???? ??????????????????? ?????????????????????????
    ????????????????????

17
  • ????????????????????????????????
    ?????????????????????????????????????????? ????
    ?????????????????? ???????????????????????,
  • ?????????????????????? ????????????????????????
    ??????? ??????????????????????????????????????????
    ???????????????????????
  • ????????????????????????????????????????
    ??????????????????????????????????????????????????
    ? ?????????????????????????????????? ???????????
    ???????????????????? ?????(???)???????????????????
    ????????

18
  • ??????????????????????????????????????????????????
    ???????????????????? ?????????????????????????????
    ??????????????????????????????????????????????
  • ?????????????????????????????????????????????????
    ??????????????????????????????????????????????????
    ?????????????????????????
  • ????????????????????? (Object-Oriented
    Programming Languages) ???? Java, C,
    SmallTalk ????????????????????????

19
Object Class
Object
Object-Program
ObjectReal-world
20
Anatomy of an Object(1)
  • An object is an abstraction and has an identity
  • An object has a name (which may or may not be
    unique)
  • An object is anything exhibits structure and
    behavior
  • - Structure
  • Attribute that define the objects
    properties
  • Each attribute takes on a single value
    for a given object
  • - Behavior
  • Operations performed on or by an object
  • Each operation is implemented via a
    method
  • Object can be related or linked to other objects

21
Anatomy of an Object(2)
22
Object Concept
  • Things
  • Tangible Things gtPhysical Things
  • Intangible Things
  • ?????(Tole) (??????? ??????? ???????)
  • ??????????????(Incident) ???? Event ?????
    ??????????
  • ?????????(Interaction) (??????? 2
    Object(???????-???))

23
1.??????????????????(??????????)
Object
Tangible Things
????????????????? ???? ??????,??????
24
Intangible Things ?????(Tole) (???????
??????? ???????) ??????????????(Incident)
???? Event ????? ?????????? ?????????(Interact
ion) (??????? 2 Object(???????-??????))
2.??????????????????(?????????????)
Object
  • ?????????
  • ???????
  • ???
  • ???????????????

25
Object Concepts
  • Object a thing thats a member of a class
  • Examples
  • Dwell here a while CLASS vs. OBJECT
  • Objects contain attributes behaviors
  • Organization
  • Generalization/specialization hierarchies
  • Whole/part hierarchies

26
Object Class (Cont.)
Person
(Person) John Chan
Person Mary Lee
Person Nelson Sze
Class
Objects
27
Object Class (Cont.)
  • Attribute
  • An observable property of objects in a class
  • Each object in the class has a value for each
    attribute
  • The value may or may not be unique for an
    individual object

28
Object Class (Cont.)
Person
(Person) John Chan 30
Person Mary Lee 24
Person Nelson Sze 60
Name String Age int
Class with attributes
Objects
29
Object Class (Cont.)
  • Operation
  • A function or transformation that may be applied
    to or by an object in a class e.g. Debit, Credit
  • All objects in a class share the same operations
  • Each operation has the current object as an
    implicit argument

30
Object Class (Cont.)
  • Method - The implementation of an operation in a
    class
  • Query - An operation which merely computes a
    value without modifying any object

31
Object Class (Cont.)
Person
Name Age
Attributes
Change Job Change Address Get Address Get Job
Operations
32
Class and Object
Employee
Employee
Employee
nameString
nameSmith
nameSharp
age24
age52
ageInteger
Objects instantiated from the class Employee
Class Employee
33
Representing Objects
  • An object is represented as rectangles with
    underlined names

Professor
a b 10
a b 10
ProfessorClark
Class Name Only
ProfessorClark Professor
Object Name Only
Class and Object Name
(stay tuned for classes)
34
What is a Class?
  • A class is a description of a group of objects
    with common properties (attributes), behavior
    (operations), relationships, and semantics
  • An object is an instance of a class
  • A class is an abstraction in that it
  • Emphasizes relevant characteristics
  • Suppresses other characteristics

OO Principle Abstraction
35
Sample Class
Class Course
Properties Name Location Days offered Credit
hours Start time End time
Behavior Add a student Delete a student Get
course roster Determine if it is full
a b 10
36
Representing Classes
  • A class is represented using a compartmented
    rectangle

a b 10
Professor
Professor Clark
37
Representing Classes in the UML
  • A class is represented using a rectangle with
    compartments.

Professor J Clark
38
The Relationship Between Classes and Objects
  • A class is an abstract definition of an object
  • It defines the structure and behavior of each
    object in the class
  • It serves as a template for creating objects
  • Objects are grouped into classes

Objects
Class
Professor
39
Basic Principles of Object Technology
??????????????????????????????????????????????????
? ???????????????
40
About the Java Technology .?
41
Write once, run anywhere
  • "???????????????? ?????????????? ???????????????
    ?????????????????????"

?????????????????????? .. Consistently ??????
????????????????????????? Anywhere on any
platform ????????????? ???????????????????? Reli
ability ??????????? Security ??????? Low
Risk ????????????? ??????????
?????????????????????? C, JAVA, Small Talk,
Object Pascal,VBasic ??? We
choose "JAVA".
42
Java technology is both a programming language
and a platform.
About the Java Technology .?
Java Platforms A platform is the hardware or
software environment in which a program runs.
43
A Virtual Machine
  • ???????????????? Compiler ??? Interpreter

Compiler ???? Compile ????????????? ??? Compile
???? ByteCode Interpreter ?????????????????
ByteCode ???????????? Load ??????????????????????
???? ???????? ByteCode ???????????????????????????
????
44
Byte Code and Java Virtual Machine
  • Existing Development Environment

cc Hello.c o Hello Hello
Binary Code
Run
45
Bytecodes and the Java Virtual Machine
  • Java Development Environment

javac Hello.java Hello.class created java Hello
Byte Code
JVM
Run
46
Java is Cross-Platform?
47
Java is Cross-Platform?
  • Truth Java programs can compile to
    machine-independent bytecode
  • Truth All major operating systems have Java
    runtime environments
  • Most bundle it (Solaris, MacOS, Windows 2k, OS/2)

Compile Time
Run Time
48
Java Platforms
  • ????????????? OS ??? Platform ???????? ??????
    ?????????? Compile ???? (Write One - Run
    Anywhere)
  • ??????????? Web Page
  • ??????????????????????? Java Virtual Machine ????
    ?????????????? ????????

49
???????????????????????(Java Technology?)
1. Java Virtual Machine (JVM)
2. Java Runtime Environment (JRE)
3. Java 2 Software Developer Kit (J2SDK)
50
1. Java Virtual Machine (JVM)
???????????????????????????????????????????
(interpreter) ??????????????????????????????????
????????? (interpreter) ??? ??????????????????????
???????????????????????? ??????????????????????
??????????????? ?????????????????? JVM
51
2.Java Runtime Environment (JRE)
  • ????????????????????????????? ?????????? 3
    ??????? ??????
  • ?????????????????? Class loader
  • ????????????????????? Bytecode Verifier
  • ????????????????? Runtime Interpreter

52
3. Java 2 Software Developer Kit (J2SDK)
  • ??????????????????????????? ??????????????????????
    ?? ??????????????? Editor ??????????? ?????????
  • ????????????????? (javac.exe)
  • ??????????????????????? (java.exe)

53
???????????????? 2 (Platform of Java 2)
Java 2 Platform, Enterprise Edition (J2EE)
Java 2 Platform, Standard Edition (J2SE)
Java 2 Platform, Micro Edition (J2ME)
54
Java 2 Platform, Standard Edition (J2SE)
  • ????????????????????????????????????
  • ???????????????????????????? ?????????? Java
    Application (???????????????????) ???
  • Java Applet (???????????????????????????? ???? IE)

55
Java Application (???????????)
Class
Byte code Byte code Byte code Byte code
Java.exe
Javac.exe
compile
????
Byte code file (.class)
Source code (.java)
Windows
Unix
Linux
JVM
JVM
JVM
56
Java Applete(??????????? )
Java app
applets
Browser
JVM
JVM
application
Operating System
Hardware
57
Java 2 Platform, Enterprise Edition (J2EE)
  • ??????????????????????????????????
  • ???????????????? ????????????????????
    ????????????? Application Server ???? Web Server
  • ???????????????????????????? ?????????????????????
    ??????????????????????????? Servlets, JSP??? XML

58
Java 2 Platform, Micro Edition (J2ME)
  • Java 2 Platform, Micro Edition (J2ME)
    ??????????????????????????????????????????
  • ???????????????????????? ?????????????????? ????
    ???????????????? (PDA Personal
  • Digital Asistance)

59
Standard Java ?????????????????? ?????
  • Sun JDK http//java.sun.com/
  • Standard 1.0 JDK 1.0 Old
  • Standard 1.1 JDK 1.1 , 1.1.6, 1.1.8 Still
    using
  • Standard 2 JDK 1.2 , 1.2.2 , 1.3,1.4,1.5
    Current
  • Microsoft JDK 4.0
  • IBM JDK 1.1.8
  • ?? JDK ???????????? Compiler, JVM, Class
    library, Documents,Demos and Tools

60
???????????????????
  • ???????? Java Application / Java Applet
  • ????????? Syntax
  • ?????? Standard Class Library
  • ???????????? OOP
  • ????? Application ???????????
  • ?????????????????? Java Class/Components
  • ????? Object Orient Design/UML
  • ????? Design Pattern/Framwork
  • ????????????????????????
  • ????????????????? Java ???????? Java2D, Java3D,
    JDBC, J2EE ....

To be Java Master. You must coding, coding and
coding
61
Java Development Kit
  • Jbuilder By Borland
  • Microsoft Visual J
  • Semantec Cafe
  • Jfactory by Rouge Wave
  • IBM Visual Age for Java
  • NetBean IDE 6.1

62
  • Real J (Free 487 Kb)???? Java IDE ????????
    ???????????????????????????????????? ?????????
    FREE ??????????? freejava ????????????????????????
    ???? java ?????????????????????? sun (??????????)
    ???????????????? RealJ ???????????? JCreator
    ?????? RealJ ????????? Font ?????????????????????
    Homepage http//www.realJ.com/
  • BlueJ 2.1.3
  • Jeliot 3.0

63
?????????????
64
??????
  • ??????????????????
  • ????????????????
  • ?????????????
  • ???????????????????????????????
  • ??????? HelloWorld ???????????????????????????

65
??????????????????
66
  • ?????????????????.?. 1990
  • ??????? ????? (Pattrick Naughton) ?????????????
  • ????? ??????? (James Gosling) ????????????????????
  • ???????
  • ????????????????????????????? (personal computer)
    ??????????????????????????????????????? (consumer
    electronics)

67
????????
  • ??? ??? (Bill Joy) ???????????????????
  • ??????????????????????????????????????????
    ???????????????????????? HotJava
  • Netscape Navigator
  • 23 ?????? ?.?. 1996 ????????? JDK 1.0

68
????????????????
69
????????????????
  • ???????????????????????
  • ??????????????
  • ????????????????????

70
????????????????
  • ??????????????????????????????????????????
  • ?????????????????????????
  • ???????????
  • ?????????????

71
????????????????
  • ?????????????????????????????????????????
    (garbage collection)
  • ?????????????????????????????????
  • 794 interfaces
  • 2485 classes
  • ???

72
?????????????
73
????????? (platform)
  • ????????????????????????
  • Hardware
  • Software

74
?????????????
  • Java 2 Platform, Standard Edition (J2SE)
  • ??????????????? (Java application)
  • ??????? (Java applet)
  • Java 2 Platform, Enterprise Edition (J2EE)
  • ????????????????????? (multitiered)
    ??????????????????????????????????
  • Java 2 Platform, Micro Edition (J2ME)
  • ???????????????????? ???? ?????????????? ??????
    (personal digital assistant) ???????????????????
    (TV set-top box

75
???????????????????????????????
76
???????????????? (JDK)
  • ???????????????? (Java Development Kit - JDK)
  • ?????????????? (javac.exe)
  • ???????????????????????????? (Java Runtime
    Environment - JRE) (java.exe)
  • Download http//java.sun.com

77
????????????????????????????????
  • Notepad
  • ?????????? Windows
  • J-Lab
  • http//www.cp.eng.chula.ac.th/somchai/JLab/
  • Netbeans
  • http//www.netbeans.org/
  • Eclipse
  • http//www.eclipse.org/

78
Notepad
79
J-Lab
80
Netbeans
81
Eclipse
82
??????? HelloWorld ???????????????????????????
83
??????? HelloWorld
  • ?????????? Hello, World! ???????????????????????

84
?????????????? cmd
2
1
3
85
??????????????
86
??????? HelloWorld
  • public class HelloWorld

87
??????? HelloWorld
  • public class HelloWorld
  • public static void main(String args)

88
??????? HelloWorld
  • public class HelloWorld
  • public static void main(String args)
  • System.out.println("Hello, World!")

89
??????? HelloWorld ?????????
90
??????? HelloWorld ?????????
  • import java.awt.
  • import javax.swing.
  • public class HelloGraphicsWorld
  • public static void main(String args)
  • JFrame frame new JFrame()
  • public void paint(Graphics g)
  • g.drawString("Hello, World!",
    110, 150)
  • g.drawOval(100, 130, 90, 30)
  • frame.setSize(300, 300)
  • frame.setDefaultCloseOperation(WindowConst
    ants.EXIT_ON_CLOSE)
  • frame.setVisible(true)

91
?????????????????
  • ???????????????????
  • // print the word hello
  • ??????????????????????
  • /
  • This program
  • will print
  • the word hello
  • /

92
?????????????????
  • ??????????????????????????????????????????????????
    ??? javadoc
  • /
  • /

93
????
94
????
  • ???????????????????????????????????????????????
    ??????????? ??? ???????
  • ??????????????????????????????????????????????????
    ? ????????????????????????????????????????????????
    ???????? ?????????????????????????????????????????
    ?????
  • ??????????????????????????????????
    ??????????????????????????????????????????????????
    ?????? ???????????????????????????????????????????
    ???????????????????????????????????????

95
????
  • ?????????????????????????????????????????? java
  • ???????????????????????????????? javac
  • ????????????????????????????????? class
  • ??????????? class ????????????? JRE ???
  • ?????????? java ??????? .class ?????????? main()
  • ???????????????????????? System.out.println("????
    ??????????????????")

96
?????????
  • Ex1. ???????????? HelloWorld ???????????????????

97
???? Ex1.
public class Ex1 public static void
main(String args)
System.out.println("Hello, World!")
98
????????? ????? 1
  • Ex2. ????????????????????????????????????
    ????????????????? Hello ????????????????????
    World

99
???? Ex2.
public class Ex2 public static void
main(String args)
System.out.println("Hello")
System.out.println("World")
100
????????? ????? 1
  • Ex3. ?????????????????????????????????
    Hello,World ????????????????????
    ??????????????????????????????????????????
  • public class Ex3
  • public void main(string args)
  • system.out.print(Hello)
  • system.out.print(,World)

101
???? Ex3.
public class Ex3 public static void
main(String args)
System.out.print("Hello")
System.out.print(", World!")
102
??????
Write a Comment
User Comments (0)
About PowerShow.com