Title: Topic: Java in the Computer World
1Topic Java in the Computer World
2Computer Software vs. Hardware
3Programming languages
- High-level languages
- single statements could
- be written to accomplish
- substantial tasks.
- Assembly languages
- English-like abbreviations
- elementary operations
- Machine languages
- 1's and 0's
- machine-dependent
High-level language
Assembly language
Machine language 0111010
4 Example (Programming languages)
- Machine languages
- 1300042774
- 1400493419
- 1200274027
- Assembly languages
- LOAD BASEPAY
- ADD OVERPAY
- STORE GROSSPAY
- High-level languages
- grossPay basePay overTimePay
5Java Software Development Environment
- You can have 4 separate parts
- Editor
- Compiler
- Interpreter
- Debugger
- Or you can combine some of these parts
6(No Transcript)
7Integrated Development Environment (IDE)
- IDE combins
- editor, compiler, interpreter and debugger
- IDE is a tool for developing software
- This course is not about IDE
- This course is about designing software
8Where is Java in the compter world? -- section
summary
High-level language
Assembly language
Machine language 0111010
9Topic Object Oriented Design
10Section I Classes
Classes
- Classification
- The classification process
- Classification is good
- Classification takes places in everyday life
11Classes -- How to classify
Classes
- Example
- object group gtclasses
- class monitor (output device)
- class printer (output device)
- class speaker (output device)
- class computer tower (computing device)
- class keyboard (input device)
- class mouse (input device)
12Class and Object Relation
Classes
- An object is an instance of a class
- A class represents a category of objects
obj
obj
Class monitor
Class printer
obj
obj
13Class and method relation
Classes
14Why Different Classes?
Classes
- Good thing about such modular design
- Independent objects gtlocal problem only
- Example
- bad keyboard, but everything else is still
working fine - Easy to find problems
- try a new keyboard --gt find out the old keyboard
is bad - Easy to fix problems
- buy a new keyboard for 15
- If the system does not have such modular design
- wed be in trouble.
15Sub-class
Classes
- A big class might have sub-classes
- Good vs. bad classification
- Example make sub-classes for books in a
bookstore - Good classification
- literature, arts, science, religion, sports,
home, map - Bad classification
- alphabetically order books section A,B,C...
16About Classes section summary
Classes
- We have learned
- Classification is good
- classification categorization
- (motivated why we want to split things into
classes - Good classification vs. bad classification
- Sometimes, a class has sub-classes
17About Classes section summary (continue)
Classes
obj
- Also, we have learned...
- An object is an instance of a class
- A method is inside of a class
Class monitor
obj
18Section II Methods
Methods
- Each method belongs to a class
- A class can have many methods
19Make Methods (Example)
Methods
- Example make up some methods for the printer
class - What does a printer do?
- Lets draw a flow chart...
20Methods
21Flow chart --gt Methods
methods
- Flow chart
- help us to think through
- breaks big task to smaller sub-tasks
- small sub-tasks gt methods
- Each method is an action
- Now, we are ready to write the skeleton of class
printer...
22- //------------------------------------
- // class Printer
- //------------------------------------
- class Printer
-
- //---------------------------
- // define variables
- //---------------------------
- boolean double_sided // The
variable "double_sided" -
// as type "boolean", so it can -
// take only values "true" or "false". - int maximum_memory_size // The maximum
size of the memory -
// is an integer. Type "int"integer. - //-------------------------------------
- // Method receive_file
- // DOES Receive files to be printed.
- //--------------------------------------
- void receive_file()
methods
23About Methods section summary
methods
- In this section, we learned that
- A class consists of many/some methods
- A class might have methods to handle some tasks
- Break a big task into small sub-tasks
- method sub-tasks (manageable sub-tasks)
- often, mehtods gt an action
24Topic Summary Class and method
- Class ltgt classification
- class ltgt modular design
- class (method) (method)
- big task (small sub-task) (small sub-task)
... - Methods ltgt small sub-task
- We are happy -- that we designed a nice schematic
Printer class.
25Programming process
ideas
Program text, on paper or in head
Work done at the keyboard with a text editor
Compiler-- a program for translating programs
Program in Java byte code, in the file
Test.class
Program text, in a file such as Test.java
Java Virtual Machine JVM, executes the program
Test.class