Download presentation
Presentation is loading. Please wait.
Published byAntonia Daniela Bryan Modified over 8 years ago
1
Computer Software vs. Hardware
2
Topic: Java in the Computer World
3
Programming 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 Machine language : 0111010 Assembly language High-level language
4
Example (Programming languages) Machine languages: +1300042774 +1400493419 +1200274027 Assembly languages: LOAD BASEPAY ADD OVERPAY STORE GROSSPAY High-level languages: grossPay = basePay +overTimePay
5
Java Software Development Environment You can have 4 separate parts: –Editor –Compiler –Interpreter –Debugger Or you can combine some of these parts
7
Integrated 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
8
Where is Java in the compter world? -- section summary Machine language : 0111010 Assembly language High-level language
9
Topic: Object Oriented Design Classes Methods
10
Classes = Classification = The classification process Classification is good Classification takes places in everyday life Classes
11
Classes -- How to classify Example object group ==>classes –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) Classes
12
Class and Object Relation An object is an instance of a class A class represents a category of objects Class monitorClass printer obj Classes
13
Class and method relation Classes
14
Why Different Classes? Classes Good thing about such modular design: –Independent objects ==>local problem only Example –bad keyboard, but everything else is still working fine –Easy to find problems –try a new keyboard --> 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 we’d be in trouble.
15
Sub-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...
16
About Class: 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
17
About Class: section summary (continue…) Classes Also, we have learned... –An object is an instance of a class –A method is inside of a class Class monitor obj
18
Methods Each method belongs to a class A class can have many methods
19
Make Methods (Example) Methods Example: make up some methods for the printer class What does the printer do? –Let’s draw a flow chart...
20
Methods
21
Flow chart --> Methods Flow chart –help us to think through –breaks big task to smaller sub-tasks –small sub-tasks ==> methods Each method is an action Now, we are ready to write the skeleton of “class printer”... methods
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() { //... // We don't know how to program the method yet. } methods
23
About Methods: section summary 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 ==> an action methods
24
Topic Summary: Class and method Class classification class modular design class = (method) + (method) +… big task = (small sub-task) + (small sub-task) +... Methods small sub-task We are happy -- that we designed a nice schematic Printer class.
25
Programming process ideas Program text, on paper or in head Work done at the keyboard with a text editor Program text, in a file such as Test.java Compiler-- a program for translating programs Program in Java byte code, in the file Test.class Java Virtual Machine JVM, executes the program Test.class
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.