1. Trang chủ
  2. » Công Nghệ Thông Tin

Lecture An introduction to computer science using java (2nd Edition): Chapter 1 - S.N. Kamin, D. Mickunas, E. Reingold

22 71 0
Tài liệu được quét OCR, nội dung có thể không chính xác

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Cấu trúc

  • Chapter 1 What is Programming?

  • Chapter Preview

  • Definitions

  • Final Maze Solving Program

  • Object-Oriented Programming

  • PowerPoint Presentation

  • Slide 7

  • Object-Oriented Programming and Java

  • Computer Organization

  • Slide 10

  • Running a Program

  • Slide 12

  • Data Representation

  • Slide 14

  • Slide 15

  • Slide 16

  • Slide 17

  • Slide 18

  • Slide 19

  • Running Your Own Java Program

  • Errors

  • Java

Nội dung

Chapter 1 - What is programming? In this chapter we will: demonstrate some problem-solving techniques needed in programming, design an algorithm to solve a problem, write a program to implement an algorithm, discuss the importance of object-oriented programming, discuss some basics of computer hardware, describe the process of entering and running Java programs.

Trang 1

Chapter 1

What is Programming?

Lecture Slides to Accompany

An Introduction to Computer Science Using Java (2nd Edition)

by

Trang 2

Chapter Preview

In this chapter we will:

¢ demonstrate some problem-solving techniques

needed in programming

¢ design an algorithm to solve a problem

¢ write a program to implement an algorithm ¢ discuss the importance of object-oriented

programming

* discuss some basics of computer hardware

Trang 3

Definitions

* program — a set of directions telling a computer exactly what to do * programming languages — languages for specifying sequences of directions to a computer ¢ algorithm

— a sequence of language independent steps which

Trang 5

Object-Oriented Programming

A modern programming paradigm that allows the programmer to model a problem in a real- world fashion

Objects interact with each other by sending

messages

An object is an instance of a class

Trang 8

Object-Oriented Programming and Java

¢ The use of OOP in Java Is pervasive

— easy to create multiple objects of the same type — easy to create similar objects without having to

rewrite the overlapping code

¢ OOP makes programs easier to understand and more reliable

Trang 10

Central Input processing | ` Main c— keyboard

unit memory camera

Trang 11

Running a Program

First the program and all its data is copied from the hard disk into main memory

The CPU goes to the location of the program

Instruction and reads that word

The CPU determines what action is requested by decoding its bit pattern representation

The CPU performs the action

The CPU then moves to the location of the next

program instruction in memory, reads the word, and

Trang 13

Data Representation

¢ Computers use binary numbers

¢ Numbers can be used to represent any type of data

— pictures are represented by dividing them into picture elements known as pixels

— video images or animations are represented by

placing several picture one after another

— sounds are represented by sampling the wave at regular intervals

Trang 15

Animation is represented as a sequence of pictures Each picture is a sequence of numbers First

picture: 0, 0, 0, 128, 0, 0, 0; Second picture: 0, 0, 128, 192, 128, 0, 0; Third picture: 0, 128, 192, 224, 192, 128, 0 Place two numbers at beginning, giving height and width of each picture: 7, 8, 0, 0, 0, 128,

Trang 19

prog1.java — JAVA 01110100 01101000 01001011

Programmer types program using a fext editor File is stored on disk with type “JAVA.” Text is represented in binary Java compiler runs in CPU

prog1.java prog1.class

Trang 20

Running Your Own Java

Program

Enter the program source code in a data file using an editor

Transform the source program into machine language or Java Bytecode using an compiler (e.g Javac)

Use an interpreter to execute the compiled program (e.g Java)

Trang 21

Errors

Debugging \s the process of detecting and fixing errors found in a program

Syntactic errors are caused by giving the compiler a program It cannot recognize

Logical errors come from programs that compile correctly but fail to execute as expected

Programs must be designed carefully and

Trang 22

Java

¢ applications — stand-alone programs that run on you own computer — can read and write data on your disk disk ¢ applets

— executed from within a browser window (e.g

Netscape or Internet Explorer)

— can be loaded from the World Wide Web and

executed on another computer

Ngày đăng: 11/01/2020, 19:29

TỪ KHÓA LIÊN QUAN