איריס צור ברגורי יסודות – עצמים תחילה כנס מורי מדעי המחשב, תשס " ז.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

The Point Class public class Point { public double x; public double y; public Point(double x0, double y0) { x = x0; y = y0; } public double distance(Point.
Inheritance // A simple class hierarchy. // A class for two-dimensional objects. class TwoDShape { double width; double height; void showDim() { System.out.println("Width.
Lecture 28: Abstract Classes & Inheritance Announcements & Review Lab 8 Due Thursday Image and color effects with 2D arrays Read: –Chapter 9 Cahoon & Davidson.
1 Lecture 06(Abstract Classes)Lecture 9 Abstract Classes Overview  Abstract Classes: A Definition.  Declaring Abstract Classes.  Abstract Methods: A.
Review 4 View classes as modules –Encapsulate operations –functions are static methods 4 View classes as struct types –Encapsulate data class C {...} C.
1 Overloading vs. Overriding b Don't confuse the concepts of overloading and overriding b Overloading deals with multiple methods in the same class with.
Aspect-Oriented Software Development (AOSD) Tutorial #3 AspectJ - continued.
UML Basics & Access Modifier
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved COS240 O-O Languages AUBG,
Computer Science [3] Java Programming II - Laboratory Course Lab 1 + 2: Review inheritance & abstract Review inheritance & abstractPolymorphism Faculty.
תרגול 13 חזרה 1. Exam example 8 public class Stam { private char x; public Stam() { this.x = '*'; } public Stam (char c) { this.x = c; } public Stam getStam()
CSC 205 Java Programming II Polymorphism. Topics Polymorphism The principle of substitution Dynamic binding Object type casting Abstract class The canonical.
10-Nov-15 Java Object Oriented Programming What is it?
Cross cutting Cross-cutting of components and aspects ordinary program structure-shy functionality structure synchronization better program Components.
Inheritance. What Is Inheritance? Familiar examples: –A family tree (individuals inherit characteristics from other individuals) –A taxonomy (classes.
 Definition: Accessing child class methods through a parent object  Example: Child class overrides default parent class methods  Example: Child class.
The Class Construct Defining objects with attributes and behavior JPC and JWD © 2002 McGraw-Hill, Inc.
Some odds and ends about Classes and Objects. 6-2 Object-Oriented Programming Object Data (Fields) Methods That Operate on the Data.
1 運算子多載 鄭士康國立台灣大學 電機工程學系 / 電信工程研究所 / 資訊網路與多媒體研究所.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Review Creating Objects Pepper many references from rial/java/objects/object.html
More on Objects Mehdi Einali Advanced Programming in Java 1.
Peyman Dodangeh Sharif University of Technology Spring 2014.
97-2-JAVA3 第三階段考古題說明. 1 public class EX31 { public static void main(String[] argv) { Car oldcar = new Car(); Car newcar = new Car(); oldcar.eff = 10;
CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Abstract Classes Course Lecture Slides 7 June 2010 “None of the abstract.
COT int[] x = {3,7,2,4,1}; int[] y = {5,8,6,9}; x = y; x[2] = 0; for (int k: y) { System.out.print(k + " "); }
Classes and Objects - Part I. What is an Object? An Object has two primary components: state – properties of the object behavior – operations the object.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Inheritance and Abstraction Class Hierarchies, Abstract Classes, Interfaces SoftUni Team Technical Trainers Software University
1 / 71 COP 3503 FALL 2012 SHAYAN JAVED LECTURE 4 Programming Fundamentals using Java 1.
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
Object-Oriented Programming in Java How Java Implements OOP: Classes, Objects, Exceptions, Etc. SoftUni Team Technical Trainers Software University
Powerpoint slides from A+ Computer Science Modified by Mr. Smith for his course.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Import javax.swing.JOptionPane; public class Rectangle { public static void main(String[] args) { double width, length, area, perimeter; String lengthStr,
Copyright © 2016 Robert W. Hasker. exponent /-mantissa 1 bit 6 bits9 bits.
OBJECT ORIENTED PROGRAMMING
תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים
Inheritance ITI1121 Nour El Kadri.
Abstraction, Interface, Inheritance, Polymorphism, Override / Overload
using System; namespace Demo01 { class Program
Reference: COS240 Syllabus
Defining objects with attributes and behavior
IST311 Advanced Issues in OOP: Inheritance and Polymorphism
Abstract Class, Interface, Package
IST311 Advanced Issues in OOP: Inheritance and Polymorphism
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Objects in other classes:
תכנות מונחה עצמים.
CS 200 Creating Classes Jim Williams, PhD.
Functions Used to write code only once Can use parameters.
בניית מחלקות.
Object-Oriented Programming
Creating Objects in a Few Simple Steps
בניית מחלקות.
Implementing Non-Static Features
Unit-2 Objects and Classes
Announcements & Review
Example with Static Variable
Recursive GCD Demo public class Euclid {
Agenda About Homework for BPJ lesson 36 About practice of last class
class PrintOnetoTen { public static void main(String args[]) {
CSE Module 1 A Programming Primer
Inheritance in Java CS 3331 Fall 2009.
Chapter 11 Inheritance and Polymorphism
CS 200 Creating Classes Jim Williams, PhD.
CS 200 More Classes Jim Williams, PhD.
CS 200 Creating Classes Jim Williams, PhD.
Presentation transcript:

איריס צור ברגורי יסודות – עצמים תחילה כנס מורי מדעי המחשב, תשס " ז

איריס צור ברגורי  לתלמידים - לימוד חומר חדש, לא מעבר  " משבר התוכנה "  להתאים את המכונות לאדם ולא את האדם למכונות.  ילדים חושבים בעצמים : מושגים מוחשיים ( עט, מחשב, עץ, אדם, מזלג וכו ' ) מושגים מופשטים ( ציון, תפקיד, רעיון, פגישה, הסכם, חוזה וכו ') מכנים משותפים, שיוכים ( אופניים, מכוניות, מטוסים, רכבות הנם כלי תחבורה. תפוז, אגס, תפוח, בננה הנם פירות וכו '). עצמים תחילה – למה ?

איריס צור ברגורי עצמים תחילה – למה ?

איריס צור ברגורי  עבודה עם מחלקות מוכנות Turtle Bucket  כתיבת מחלקות עצמים תחילה – איך ?

איריס צור ברגורי Card private string name; Card() Card(string name) void SetName(string name) string GetName() string ToString() Cards המחלקה

איריס צור ברגורי class Card { private string name; public Card() { this.name=""; } public Card(string name) { this.name = name; } public void SetName(string name) { this.name = name; } public string GetName() { return this.name; } public override string ToString() { return ("Happy birthday " + this.name); } Cards המחלקה

איריס צור ברגורי Cards המחלקה static void Main(string[] args) { Card birthCard = new Card(); Console.Write("Card with no name: "); Console.WriteLine(birthCard.ToString()); Console.WriteLine(); Console.WriteLine("What is your name?"); string name = Console.ReadLine(); birthCard = new Card(name); Console.Write("Card with a name: "); Console.WriteLine(birthCard); Console.ReadLine(); }

איריס צור ברגורי Locker int key; Locker() Locker(int key) void SetKey(int key) int GetKey() bool Open() bool CanBeKey() string ToString() Locker המחלקה

איריס צור ברגורי Locker המחלקה class Locker { private int key; public Locker() { this.key = 132; } public Locker(int key) { if(CanBeKey(key)) this.key=key; else this.key =132; } public void SetKey(int key) { if (CanBeKey(key)) this.key = key; else this.key =132; } public int GetKey() { return this.key; } …

איריס צור ברגורי Locker המחלקה … public bool CanBeKey() { return (this.key/100+this.key%10==this.key/10%10); } public bool CanBeKey(int key) { return (key / key % 10 == key / 10 % 10); } public bool Open(int key) { return (this.key==key); } public override string ToString() { return this.key.ToString(); } } // class Locker

איריס צור ברגורי Locker המחלקה static void Main(string[] args) { Locker locker = new Locker(); //Default Ctor Console.WriteLine(locker); locker.SetKey(426); //Can not be a key; Console.WriteLine(locker); locker.SetKey(385); // A new key Console.WriteLine(locker); Console.ReadLine(); }

איריס צור ברגורי CardByAge private string name; private int age; CardByAge() CardByAge(string name) CardByAge(string name, int age ) void SetName(string name) string GetName() void SetAge(int age) int GetAge() string ToString() CardByAge המחלקה

איריס צור ברגורי CardByAge המחלקה class CardByAge { private string name; private int age; public CardByAge() { this.name=""; this.age = 0; } public CardByAge(string name) { this.name = name; this.age = 0; } public CardByAge(string name, int age) { this.name = name; this.age = age; } …

איריס צור ברגורי CardByAge המחלקה … public void SetName(string name) { this.name = name; } public string GetName() { return this.name; } public void SetAge(int age) { this.age = 0; if(age>0) this.age = age; } public int GetAge() { return this.age; } …

איריס צור ברגורי CardByAge המחלקה … public override string ToString() { string st = "Happy birthday " + this.name+"."; if(this.age==0) return (st); if(this.age<10) return (st + " you turn to be soooooo big"); if (this.age < 60) return (st + " 20"+" -כ "+" 100"+" דע "); else return (st +" 120"+ " דע "); } }// Class CardByAge

איריס צור ברגורי CardByAge המחלקה static void Main(string[] args) { Console.WriteLine("What is your name and age?"); string name1 = Console.ReadLine(); int age = int.Parse(Console.ReadLine()); CardByAge ageCard = new CardByAge(name1, age); Console.WriteLine(ageCard); Console.ReadLine(); }

איריס צור ברגורי Rectangle int x; int y; int height; int width; ConsoleColor color; Rectangle() Rectangle(int x, int y, int height, int width, ConsoleColor color) Set /Get … void MoveTo(int x, int y) void Resize(int height, int width) void Drow() Rectangle המחלקה

איריס צור ברגורי Rectangle המחלקה class Rectangle { private int x; private int y; private int height; private int width; private ConsoleColor color; public Rectangle() { } public Rectangle(int x,int y,int height, int width,ConsoleColor c) { this.x = x; this.y = y; this.height = height; this.width = width; this.color = c; }

איריס צור ברגורי Rectangle המחלקה public int GetX() { return x; } public int GetY() { return y; } public int GetHeight() { return height; } public int GetWidth() { return width; } public ConsoleColor GetColor() { return color; }

איריס צור ברגורי Rectangle המחלקה public void SetX(int x) { this.x = x; } public void SetY(int y) { this.y = y; } public void SetHeight (int h) { this.height = h; } public void SetWidth (int w) { this.width = w; } public void SetColor(ConsoleColor c) { this.color= c; }

איריס צור ברגורי Rectangle המחלקה public void MoveTo(int x, int y) { this.x = x; this.y = y; } public void Resize(int h, int w) { this.height = h; this.width = w; }

איריס צור ברגורי Rectangle המחלקה public void DrawAtConsole() { Console.ForegroundColor = this.Color; for (int x = this.x; x < this.width + this.x; x++) { Console.CursorLeft = x; Console.CursorTop = this.Y; Console.Write("*"); Console.CursorLeft = x; Console.CursorTop = this.Y + this.height - 1; Console.Write("*"); } for (int y = this.Y; y < this.height + this.Y; y++) { Console.CursorLeft = this.X; Console.CursorTop = y; Console.Write("*"); Console.CursorLeft = this.X + this.width - 1; Console.CursorTop = y; Console.Write("*"); } Console.WriteLine(); }// class Rectangle

איריס צור ברגורי Rectangle המחלקה static void Main(string[] args) { Rectangle r = new Rectangle(2,5,10,5,ConsoleColor.Red); r.Draw(); r.MoveTo(10, 10); r.Resize(7,3); Console.ReadLine(); r. DrawAtConsole(); }

איריס צור ברגורי לשאלות