slide 1 of 40. lecture a מבוא למדעי המחשב. slide 2 of 40. lecture a lesson a -...
Post on 20-Dec-2015
215 views
TRANSCRIPT
![Page 1: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/1.jpg)
Slide 1 of 40.Lecture A
מבוא למדעי המחשב
![Page 2: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/2.jpg)
Slide 2 of 40.Lecture A
Lesson A - Introduction
Unit A1 – About This Course
![Page 3: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/3.jpg)
Slide 3 of 40.Lecture A
נעם ניסןמרצה:•:(218נין רוס, חדר ב )2:00-3:00 ג’ שעת קבלה
מיכאל אוקון, מעאוויה עקש,ר שרוניי נמתרגלים:•
www.cs.huji.ac.il/~intro2cs אתר הקורס:•
ספר הקורס:•
Java software solutions / Lewis & Loftus
מבוא למדעי המחשב
![Page 4: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/4.jpg)
Slide 4 of 40.Lecture A
. Javaתכנות נכון בשפת תוכן הקורס:
מטרות הקורס:
רמות הפשטה מרובות: •ממשק ומימוש
הנדסת תוכנה•:מעבדת תכנות, מבני קורסים
נתונים
מערכות חישוב ותוכנה•:מיתוג, מסדי נתונים, קורסים
מערכות הפעלה
אלגוריתמים• :אלגוריתמים, חישוביות קורסים
מבני נתונים•:מבני נתונים, מסדי נתונים קורסים
שפה ומשמעות•:מתמטיקה, לוגיקה, קורסים
חישוביות, שפות תכנות, מהדרים
![Page 5: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/5.jpg)
Slide 5 of 40.Lecture A
נושאי הקורס
תכנות מונחה עצמים:•שימוש באובייקטיםכתיבת אובייקטיםירושהממשקים
שיטות תכנות:•רקורסיהמבני נתונים דינמייםתבניותממשק משתמש
אלמנטים בסיסיים:•מבנה התוכנית וניסוחהמשתנים וביטויםפקודותבחירותלולאותמערכיםחריגות
תיאוריה:•ניתוח זמן ריצהמה ניתן לחישוב
![Page 6: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/6.jpg)
Slide 6 of 40.Lecture A
דרישות הקורס
תרגיל תכנות כל שבוע )לפעמים כל שבועיים(. •ן ברירהיהרבה עבודה. א. מומלץ לדון עם חבריםאסור!!!!! להעתיק:דיון = דיבורים בעל פה -- אין הכנסה או הוצאה של חומר הבחנה
כתוב או מודפס.
מבחן • 50/50ציון סופי: •
רגיל נמוך ביותרתציון תרגילים יחושב בהתעלמות מציון
![Page 7: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/7.jpg)
Slide 7 of 40.Lecture A
תלמידים ללא רקע תכנותי
הקורס מיועד לכם )וגם למי שיש לו רקע(•חודש ראשון יהיה קשה מאוד )קצת משעמם למי שיש רקע(•עד סוף הקורס צפוי "יישור קו" של כולם•מנגנוני עזרה:•
שעור עזר במהלך חודש ראשון פלדמן א20:00-18:00שלישי •
ייעוץ במעבדותhttp://www.cs.huji.ac.il/~intro2cs/toranot.htmlרשימת תורנות •
שעות קבלהקבוצת דיון
![Page 8: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/8.jpg)
Slide 8 of 40.Lecture A
Lesson A - Introduction
Unit A2 - Introduction to Hardware
![Page 9: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/9.jpg)
Slide 9 of 40.Lecture A
Our abstraction of a computer
ScreenScreen KeyboardKeyboard
CPUCPU
Java Program
Java Program
MemoryMemory
DataData
![Page 10: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/10.jpg)
Slide 10 of 40.Lecture A
Computer Organization Overview
KeyboardKeyboardScreenScreen DiskDisk ModemModem
Bus
Operating System
Compiler
Our Program
…
Data
SoftwareSoftware
Random Access MemoryRandom Access Memory
CPUCPU
![Page 11: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/11.jpg)
Slide 11 of 40.Lecture A
Binary Representations
• Digital Computers only deal with 0 and 1• We don’t care (mostly) • Anything can be represented by sequences of 0 and 1:
Integers: • 13 = “0000 1101”, 14 = “0000 1110” …
Characters:• ‘A’ = “0010 0001”, ‘B’ = “0010 0010” ...
• The number of bits determines the number of items that can be represented 2 bits give 4 combinations (00, 01, 10, 11) 8 bits (a byte) give 256 combinations 32 bits (a word) give more than 4,000,000,000 combinations
![Page 12: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/12.jpg)
Slide 12 of 40.Lecture A
An Example PC Specification
• 1.1 GHz Pentium IV Processor• 256 MB RAM• 20 GB Hard Disk• 17” Display with 1280 x 1024 resolution• 56 KB Modem
![Page 13: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/13.jpg)
Slide 13 of 40.Lecture A
More about Hardware
• Much more to learn• Not the topic of this course• Other courses deal with computer hardware
Digital Systems course Computer Architecture course Digital Communications course Advanced courses
• In this course, we stick with our abstraction
![Page 14: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/14.jpg)
Slide 14 of 40.Lecture A
Lesson A - Introduction
Unit A3 – Introduction to Software
![Page 15: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/15.jpg)
Slide 15 of 40.Lecture A
Problems and Algorithms
• We need to solve a computational problem “Simulate an Boeing 767 airplane” “Convert a weight in pounds to Kg”
• An algorithm specifies how to solve it, e.g.:1. Read weight-in-pounds
2. Calculate weight-in-Kg = weight-in-pounds * 0.455
3. Print weight-in-Kg
• Computers must be given exact instructions• A computer program is a computer-executable description
of an algorithm
![Page 16: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/16.jpg)
Slide 16 of 40.Lecture A
Machine languages
• Each processor has its own machine language• An assembly language is a human-readable form of the
machine language
load R7, valueload R7, value
jgt label3jgt label3
add R7, bonusadd R7, bonus
0100 0111 1101 0011 ...0100 0111 1101 0011 ...
0101 1011 0110 0111 ...0101 1011 0110 0111 ...
0110 0111 1010 1100 ...0110 0111 1010 1100 ...
![Page 17: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/17.jpg)
Slide 17 of 40.Lecture A
• Humans prefer programming in a high level language• A compiler can translate to machine language• A Interpreter can execute high-level code
High Level Languages
load R7, valueload R7, value
jgt label3jgt label3
add R7, bonusadd R7, bonus
If )value < 0( If )value < 0(
value = value + bonusvalue = value + bonus
CompilationCompilation
![Page 18: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/18.jpg)
Slide 18 of 40.Lecture A
Operating Systems
• Provides hardware-dependant services in a hardware-independent way
• Used by application programs• OS services to users
Files Printing Communication Running programs
• OS services to application programs All of the above Memory Management User Interface Processes
![Page 19: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/19.jpg)
Slide 19 of 40.Lecture A
Lesson A - Introduction
Unit A4 – First Java Program
![Page 20: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/20.jpg)
Slide 20 of 40.Lecture A
The Java Programming Language
• Invented 1995 by James Gosling at Sun Microsystems.• Based on previous languages: C, C++, Objective-C, …• Intended to be a safe programming language for the
Internet• Common choice for first programming language
Object oriented Encourages good programming habits Very popular commercially Simpler and more elegant than C++, but similar to it Cool
![Page 21: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/21.jpg)
Slide 21 of 40.Lecture A
Hello World Program
// My First Program!!public class HelloWorld { public static void main(String[] args){ System.out.println(“Hello World!”); }}
![Page 22: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/22.jpg)
Slide 22 of 40.Lecture A
Java Program Elements
• Words Keywords Identifiers
• Constants Numbers Strings
• Symbols ( ) [ ] { } , . ; + - * /
• Comments
![Page 23: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/23.jpg)
Slide 23 of 40.Lecture A
Java Elements
// My First Program!!public class HelloWorld { public static void main(String[] args){ System.out.println(“Hello World!”); }}
Comment
Identifier Symbols
KeywordsString Constant
![Page 24: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/24.jpg)
Slide 24 of 40.Lecture A
Java Program Structure
• A program is composed of a collection of classes• Each class contains a collection of methods• Each method is composed of a sequence of instructions
(commands, statements)
![Page 25: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/25.jpg)
Slide 25 of 40.Lecture A
Java Program Structure
// My First Program!!public class HelloWorld { public static void main(String[] args){ System.out.println(“Hello World!”); }}
Class
Method
Instruction
![Page 26: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/26.jpg)
Slide 26 of 40.Lecture A
Lesson A - IntroductionUnit A5 – Running Your Program
![Page 27: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/27.jpg)
Slide 27 of 40.Lecture A
Running a Java Program
• Use an editor to enter (type) the program Save to a file named HelloWorld.java
• Use the compiler to translate the program into bytecode javac HelloWorld.java This produces a file named HelloWorld.class
• Run the program using the Interpreter java HelloWorld
![Page 28: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/28.jpg)
Slide 28 of 40.Lecture A
Java Compilation
CompilerCompilerXxx.javaXxx.java Xxx.classXxx.class
InterpreterInterpreter
Output
![Page 29: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/29.jpg)
Slide 29 of 40.Lecture A
Entering a Java Program into an Editor
![Page 30: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/30.jpg)
Slide 30 of 40.Lecture A
Running a Java Program
![Page 31: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/31.jpg)
Slide 31 of 40.Lecture A
Integrated Development Environments (IDE)
• Include a combination of: Editor Compiler Debugger Project Management
• Some Commercial IDEs Sun Forte IBM Visual Age Borland Jbuilder …
![Page 32: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/32.jpg)
Slide 32 of 40.Lecture A
Forte – Screen Capture
![Page 33: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/33.jpg)
Slide 33 of 40.Lecture A
Debugging
• You will make many errors! • Most of your time will be spent finding them and correcting
them -- debugging.• There are several types of errors:
Syntax errors • detected at compilation time
Run-time errors • the program runs and crashes
Logical errors • the program does something other than what you want it to do• It does exactly what you told it to do
• The earlier an error is caught, the easier it is to correct
![Page 34: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/34.jpg)
Slide 34 of 40.Lecture A
Lesson 1 - IntroductionUnit A6 – Introduction to Objects
![Page 35: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/35.jpg)
Slide 35 of 40.Lecture A
Large Programs
• Commercial software may require millions of lines of code• Humans can only handle about 7 things together• To construct large programs:
break the program into components then break each component, etc.
• When you use a component you only use its abstraction.• When you construct a component you forget about the
rest of the program.
![Page 36: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/36.jpg)
Slide 36 of 40.Lecture A
Interfaces
• The interface of a software component is an exact definition of what it can do
• It does not address how it does what it does• When you use a component you only consider its interface• A good component will have a clear, narrow interface
![Page 37: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/37.jpg)
Slide 37 of 40.Lecture A
Objects
• Objects are the basic components in Java• An object has an interface and an internal state.• The interface encapsulates (hides) the internal operation• The interface specifies the services the object provides
Object A that uses Object BObject A that uses Object B Object BObject B
![Page 38: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/38.jpg)
Slide 38 of 40.Lecture A
A Turtle Object
![Page 39: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/39.jpg)
Slide 39 of 40.Lecture A
A Turtle Object
• A Turtle object represents a turtle that walks on the screen with a pen on its tail
• Turtle object interface: moveForward(distance) moveRight(degrees) moveLeft(degrees) tailUp() tailDown()
• Turtle object internal state Location on screen Direction facing Tail is up or down
![Page 40: Slide 1 of 40. Lecture A מבוא למדעי המחשב. Slide 2 of 40. Lecture A Lesson A - Introduction Unit A1 – About This Course](https://reader037.vdocuments.site/reader037/viewer/2022110322/56649d4e5503460f94a2d37a/html5/thumbnails/40.jpg)
Slide 40 of 40.Lecture A
Using a Turtle
public class TurtleDrawing { public static void main(String[] args){ Turtle leonardo = new Turtle(); leonardo.tailDown(); leonardo.moveForward(100); leonardo.turnRight(60); leonardo.moveForward(100); }}