Classes and Objects. Andrew Cumming, SoC. Introduction to.net. Bill Buchanan, SoC. W.Buchanan (1)
|
|
- May Naomi Wilkerson
- 5 years ago
- Views:
Transcription
1 Classes and Objects Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1)
2 Course Outline 11-12am 12-1pm: 1-1:45pm 1:45-2pm:, Overview of.net Framework,.NET Components, C#. C# Language Elements Classes, Encapsulation, Object-Orientation, Classes, Sealed Classes, Interfaces, Abstract Classes. Certification Course Outline (Day 1 to 3) W.Buchanan (2)
3 Module 8 Classes and objects. Using encapsulation. Defining Object-Oriented Systems. Inheritance. Constructors. Sealed classes. Overriding classes. Introduction W.Buchanan (3)
4 Introduction to Object- Orientation (again!) W.Buchanan (4)
5 Some Cups W.Buchanan (5)
6 Parameter Cup 1 Cup 2 Cup3 Shape (Standard/Square/Mug) Standard Square Mug Colour (Red/Blue/Green) Blue Red Green Size (Small/Medium/Large) Small Large Small Transparency (0 to 100%) 100% 50% 25% Handle type (Small/Large) Small Small Large In object-orientation:a collection of parameters defines a class. Class for the cup is thus: Shape, Colour, Size, Transparency, HandleType. In object-orientation: Objects are created from classes. A Quick Introduction to Object-Orientation W.Buchanan (6)
7 using System; namespace ConsoleApplication2 Class definitions public class Cup public string Shape; public string Colour; public string Size; public int Transparency; public string Handle; Available variables (properties) Method public void DisplayCup() System.Console.WriteLine("Cup is 0, 1", Colour, Handle); class Class1 static void Main(string[] args) Cup cup = new Cup(); cup.colour = "Red"; cup.handle = "Small"; cup.displaycup(); System.Console.ReadLine(); Create new object Set properties Apply method Example C# Program using Object-Orientation W.Buchanan (7)
8 using System; namespace ConsoleApplication2 public class Circuit public double Parallel(double r1, double r2) return((r1*r2)/(r1+r2)); public double Series(double r1, double r2) return(r1+r2); Class definitions class Class1 static void Main(string[] args) double v1=100,v2=100; double res; Circuit cir = new Circuit(); res=cir.parallel(v1,v2); System.Console.WriteLine("Parallel resistance is 0 ohms",res); res=cir.series(100,100); System.Console.WriteLine("Series resistance is 0 ohms",res); System.Console.ReadLine(); Another example W.Buchanan (8)
9 using System; namespace ConsoleApplication2 public class Complex public double real; public double imag; public double mag() return (Math.Sqrt(real*real+imag*imag)); public double angle() return (Math.Atan(imag/real)*180/Math.PI); class Class1 static void Main(string[] args) string str; double mag,angle; Complex r = new Complex(); System.Console.Write("Enter real value >>"); str=system.console.readline(); r.real = Convert.ToInt32(str); System.Console.Write("Enter imag value >>"); str=system.console.readline(); r.imag = Convert.ToInt32(str); mag=r.mag(); angle=r.angle(); System.Console.WriteLine("Mag is 0 and angle is 1",mag,angle); System.Console.ReadLine(); z x jy z z x 2 tan y 1 2 y x Another example W.Buchanan (9)
10 Object Properties W.Buchanan (10)
11 Make. This could be Ford, Vauxhall, Nissan or Toyota. Type. This could be Vectra, Astra, or Mondeo. Colour. This could be colours such as Red, Green or Blue. Country of Manufacture. This could be countries such as UK, Germany or France. Car properties W.Buchanan (11)
12 using System; namespace sample01 public class Car private string colour; private string type; private string make; private string country; private double cost; public string Colour get return colour; set colour=value; public string Type get return type; set type=value; public string Country get return country; set country=value; public string Make get return make; set make=value; public double Cost get return cost; set cost=value; Relationship Tree class Class1 static void Main(string[] args) Car car1 = new Car(); car1.colour="red"; car1.make="ford"; car1.type="mondeo"; car1.colour="uk"; car1.cost=15000; Console.WriteLine( "Car is a " + car1.make + " " + car1.type); Console.ReadLine(); W.Buchanan (12)
13 public double Cost get return cost; Read-only Read/write public double Cost set val=value; public double Cost set val=value; get return cost; Write-only Read-only, write-only and read/write properties W.Buchanan (13)
14 public class Car private string colour; private string type; private string make; private string country; private double cost; public Car() country= UK ; public string Country get return country; W.Buchanan (14)
15 Object-Orientation W.Buchanan (15)
16 Let s Look At Real Objects W.Buchanan (16)
17 Plants Animals Minerals Backbone Vertebrates Invertebrates Skin with fur/hair. Red blooded. Warm blooded. Mammals Birds Classification W.Buchanan (17)
18 Collection Vertebrates Mammals Increasing generalisation Cats Dogs Horses Lion Tiger Domestic Relationship Tree Shared behaviours and characteristics Increasing specialisation W.Buchanan (18)
19 containers System Increasing generalisation Windows IO Drawing Component Model Design Forms Label Combo Box Button Form Class Increasing specialisation Relationship Tree W.Buchanan (19)
20 using System.Collections; using System.Windows.Forms; Derived using System.Data; namespace WindowsApplication3 class public class Form1 : System.Windows.Forms.Form containers private System.Windows.Forms.Button button1; Component Model private System.Windows.Forms.TextBox textbox1; public Form1() System InitializeComponent(); private void InitializeComponent() this.button1 = new System.Windows.Forms.Button(); this.textbox1 = new System.Windows.Forms.TextBox(); this.button1.location = new System.Drawing.Point(152, 192); this means Windows this object (which is Form1) this.button1.name = "button1"; this.button1.tabindex = 0; this.button1.text = "button1"; this.textbox1.location = new System.Drawing.Point(80, 64); this.textbox1.name = "textbox1"; this.textbox1.text = "textbox1"; this.controls.add(this.textbox1); Design Forms this.controls.add(this.button1); this.name = "Form1"; this.text = "Form1"; this.load += new System.EventHandler(this.Form1_Load); this.resumelayout(false); static void Main() Label Relationship Tree Combo Box Application.Run(new Form1()); private void Form1_Load(object sender, System.EventArgs e) Base class W.Buchanan (20)
21 Constructors W.Buchanan (21)
22 A constructor is a method that is called whenever the object is first created. A destructor is a method that is called whenever the object is destroyed. Constructors and destructors W.Buchanan (22)
23 class Profile string code, name, telephone; // Constructor public Profile(string c) code=c; public string Name set name=value; get return name; public string Telephone set telephone=value; get return telephone; public void Display() Console.WriteLine("Code: " + code + " Name: " + name + " Telephone: " + telephone); Console.ReadLine(); W.Buchanan (23)
24 class Profile string code, name, telephone; // Constructor public Profile(string c) code=c; public string Name set name=value; get return name; public string Telephone set telephone=value; pf1.telephone="123456"; pf1.display(); get return telephone; public void Display() class Class1 static void Main(string[] args) Profile pf1=new Profile("00000"); pf1.name="fred Smith"; Console.WriteLine("Code: " + code + " Name: " + name + " Telephone: " + telephone); Console.ReadLine(); W.Buchanan (24)
25 using System; namespace sample01 public class Car private string colour; private string type; private string make; private string country; private double cost; public Car() public Car(string m) make=m; public Car(string m, string t) make=m; type=t; W.Buchanan (25)
26 using System; namespace sample01 public class Car private string colour; private string type; private string make; private string country; private double cost; public Car() public Car(string m) make=m; public Car(string m, string t) make=m; type=t; class Class1 static void Main(string[] args) Car car1 = new Car(); car1.colour="blue"; car1.make="ford"; car1.type="mondeo"; car1.colour="uk"; car1.cost=15000; Car car2 = new Car("Ford","Mondeo"); car2.colour="red"; car2.colour="uk"; car2.cost=12000; W.Buchanan (26)
27 W.Buchanan (27)
28 Static and Instance Members W.Buchanan (28)
29 A class can either have static members of instance members. Instance members relate to the object created, while static members can be used by referring to the name of the method within the class. For example the following are calls to static members: Convert.ToInteger("str"); Console.WriteLine("Hello"); Whereas in the following, there are two instance methods (Read() and Write()), these operate on the created data type: System.IO.StreamReader nn = new StreamReader(); nn.read(); nn.write(); Instance members thus operate on an instance of a class. Static and instance members W.Buchanan (29)
30 using System;.. class Profile static int numberprofile=0; string code, name, telephone; // Constructor public Profile(string c) numberprofile++; code=c; class Class1 static void Main(string[] args) Profile pf1=new Profile("00000"); pf1.name="fred Smith"; pf1.telephone="123456"; Profile pf2=new Profile("00001"); pf2.name="fred Cannon"; pf2.telephone="223456"; Profile pf3=new Profile("00002"); pf3.name="fred McDonald"; pf3.telephone="323456"; Profile.HowMany(); public static void HowMany() Console.WriteLine("There are " + numberprofile + " profiles "); Console.ReadLine(); Using a static member to count the number of instances W.Buchanan (30)
31 Tutorial Session 8: Q8.1-Q8.7 Presentations Notes SourceCode Tutorials W.Buchanan (31)
32 Inheritance W.Buchanan (32)
33 Inheritance Derives characteristics and behaviours from those above us. Inheritance W.Buchanan (33)
34 using System; namespace ConsoleApplication1 class People private string name; public string Name containersget return name; set name=value; public void ToLowerCase() name=name.tolower(); Inheritance System class Profile : People // Inherit from People public void Display() Windows Console.WriteLine("Name: "+Name); class Test Component static void Main() Forms Model Profile p1 = new Profile(); p1.name="fred"; Design p1.tolowercase(); p1.display(); System.Console.ReadLine(); Combo Label Box Inherent from People Method derived from People People Name: fred Profile W.Buchanan (34)
35 using System; namespace ConsoleApplication1 class People private string name; public string Name containersget return name; set name=value; public void ToLowerCase() name=name.tolower(); Design Inheritance Label System class Profile : People // Inherit from People public void Display() Windows Console.WriteLine("Name: "+Name); class Test Component static void Main() Forms Model Profile p1 = new Profile(); Profile p2 = new Profile(); p1.name="fred"; p2.name="bert"; p1.tolowercase(); p1.display(); p2.display(); Combo Box System.Console.ReadLine(); Inherent from People People Name: fred Name: Bert Profile W.Buchanan (35)
36 using System; namespace ConsoleApplication1 sealed class People private string name; public string Name containersget return name; set name=value; public void ToLowerCase() name=name.tolower(); Sealed Classes System class Profile : People // Inherit from People public void Display() Windows Console.WriteLine("Name: "+Name); class Test Component static void Main() Forms Model Profile p1 = new Profile(); p1.name="fred"; Design p1.tolowercase(); p1.display(); System.Console.ReadLine(); Combo Label Box Inherent from People People Profile 'ConsoleApplication1.Profile' : cannot inherit from sealed class 'ConsoleApplication1.People' W.Buchanan (36)
37 Overriding Classes W.Buchanan (37)
38 using System; namespace ConsoleApplication1 class People private string name; class Profile : People // Inherit from People public void Display() Console.WriteLine("Name: "+Name); Name: Fred public override void ToLowerCase() Console.WriteLine("Method has been overwritten"); Overriding classes public string Name get return name; set name=value; public virtual void ToLowerCase() name=name.tolower(); class Test static void Main() Profile p1 = new Profile(); p1.name="fred"; p1.tolowercase(); p1.display(); System.Console.ReadLine(); Method has been overwritten W.Buchanan (38)
39 Object Equals(). Determines if two objects are the same. Finalize(). Cleans up the object (the destructor). GetHashCode(). Allows an object to define its hash code. GetType(). Determine the type of an object. MemberwiseClone(). Create a copy of the object. ReferenceEquals(). Determines whether two objects are of the same instance. ToString(). Convert an object to a string. Methods for the default object W.Buchanan (39)
40 using System; namespace ConsoleApplication1 class People private string name; public string Name get return name; set name=value; public virtual void ToLowerCase() name=name.tolower(); class Profile : People // Inherit from People public void Display() Console.WriteLine("Name: "+Name); public override string ToString() return("cannot implement this method"); class Test static void Main() Profile p1 = new Profile(); p1.name="fred"; string str=p1.tostring(); Console.WriteLine(str); System.Console.ReadLine(); W.Buchanan (40)
41 Abstract Classes W.Buchanan (41)
42 Here is the new object, but you can t use it unless you implement your own OpenTheBox() method! Okay. It s worth it. I ll do that. Abstract Classes W.Buchanan (42)
43 An example W.Buchanan (43)
44 using System; namespace ConsoleApplication1 abstract class People private string name; public string Name get return name; set name=value; public void ToLowerCase() name=name.tolower(); abstract public void DisplayLower(); class Profile : People // Inherit from People public void Display() Console.WriteLine("Name: "+Name); class Test static void Main() Profile p1 = new Profile(); p1.name="fred"; p1.tolowercase(); p1.display(); p1.displaylower(); System.Console.ReadLine(); 'ConsoleApplication1.Profile' does not implement inherited abstract member 'ConsoleApplication1.People.DisplayLower()' Abstract Classes W.Buchanan (44)
45 using System; namespace ConsoleApplication1 abstract class People private string name; class Test static void Main() Profile p1 = new Profile(); public string Name get return name; set name=value; public void ToLowerCase() name=name.tolower(); abstract public void DisplayLower(); class Profile : People // Inherit from People public void Display() Console.WriteLine("Name: "+Name); public override void DisplayLower() Console.WriteLine("Name: "+Name.ToUpper()); Abstract Classes p1.name="fred"; p1.tolowercase(); p1.display(); p1.displaylower(); System.Console.ReadLine(); Name: fred Name: FRED W.Buchanan (45)
46 Interfaces W.Buchanan (46)
47 Pweh! You re rather strict. Here is the new object, but you must implement it in every way that I have defined! Interfaces W.Buchanan (47)
48 R T r 1 r 2 R 1 R 2 r 1 Circuit r 2 R T R R 1 1 R 2 R 2 Circuit Object W.Buchanan (48)
49 r 1 r 2 R T R 1 R 2 r 1 r 2 interface NewCircuit double r1 set; get; double r2 set; get; double calcparallel(); double calcseries(); R T R R 1 1 R 2 R 2 Interface Definition W.Buchanan (49)
50 r 1 r 2 public class Circuit: NewCircuit private double res1, res2; public double r1 r 1 set res1=value; get return res1; public double r2 r 2 set res2=value; get return res2; public double calcparallel() return((r1*r2)/(r1+r2)); public double calcseries() return(r1+r2); Derived Class Definition R T R T R 1 R 2 R R 1 1 R 2 R interface NewCircuit double r1 set; get; double r2 set; get; double calcparallel(); double calcseries(); 2 W.Buchanan (50)
51 r 1 r 2 public class Circuit: NewCircuit private double res1, res2; public double r1 set res1=value; get return res1; public double r2 set res2=value; get return res2; public double calcparallel() return((r1*r2)/(r1+r2)); public double calcseries() return(r1+r2); Derived Class Definition r 1 r 2 R T public class Class1 R T static void Main() R 1 R 2 R R 1 1 R 2 R Circuit cir = new Circuit(); cir.r1=1000; cir.r2=1000; double res = cir.calcparallel(); System.Console.WriteLine( "Parallel Resistance is " + res); System.Console.ReadLine(); 2 W.Buchanan (51)
52 Standard Interfaces W.Buchanan (52)
53 ICollection. Defines size, enumerators and synchronization methods for all collections. The public properties are: Count, IsSynchronized and SyncRoot, and a method of CopyTo(). IComparer. Compares two objects. The associated method is Compare(). IEnumerator. Supports iteration over a collection. The properties are Current, and the methods are MoveNext() and Reset(). IList. Represents a collection of objects that are accessed by an index. The properties are IsFixedSize, IsReadOnly, Item, and the methods are: Add(), Clear(), Contains(), IndexOf(), Insert(), Remove() and RemoveAt(). W.Buchanan (53)
54 W.Buchanan (54)
55 The ICollection defines: The classes which implement ICollection include: Array. ArrayList. Hastable. Thus an array will have the following properties: Count. IsSynchronized. SyncRoot W.Buchanan (55)
56 W.Buchanan (56)
57 Tutorial Session 8: Q8.7-Q8.10 Presentations Notes SourceCode Tutorials W.Buchanan (57)
Classes and Objects. Andrew Cumming, SoC. Introduction to.net. Bill Buchanan, SoC. W.Buchanan (1)
Classes and Objects Andrew Cumming, SoC Introduction to.net Bill Buchanan, SoC W.Buchanan (1) Course Outline Introduction to.net Day 1: Morning Introduction to Object-Orientation, Introduction to.net,
More informationIntroduction to.net. Andrew Cumming, SoC. Introduction to.net. Bill Buchanan, SoC. W.Buchanan (1)
Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components. C#. Day 1: Afternoon
More informationIntroduction to.net. Andrew Cumming, SoC. Introduction to.net. Bill Buchanan, SoC. W.Buchanan (1)
Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline 11-12am 12-1pm: 1-1:45pm 1:45-2pm:, Overview of.net Framework,.NET Components, C#. C# Language Elements Classes, Encapsulation, Object-Orientation,
More information.NET XML Web Services
.NET XML Web Services Bill Buchanan Course Outline Day 1: Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components. C#. Introduction to Visual Studio Environment..
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More information6: Arrays and Collections
6: Arrays and Collections Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationIntroduction to.net. Andrew Cumming, SoC. Introduction to.net. Bill Buchanan, SoC. W.Buchanan (1)
Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components. C#. Day 1: Afternoon
More informationBlank Form. Industrial Programming. Discussion. First Form Code. Lecture 8: C# GUI Development
Blank Form Industrial Programming Lecture 8: C# GUI Development Industrial Programming 1 Industrial Programming 2 First Form Code using System; using System.Drawing; using System.Windows.Forms; public
More informationUser-Defined Controls
C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed
More informationClasses in C# namespace classtest { public class myclass { public myclass() { } } }
Classes in C# A class is of similar function to our previously used Active X components. The difference between the two is the components are registered with windows and can be shared by different applications,
More informationModule 5: Review of Day 3
Module 5: Review of Day 3 Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More informationModule 5: Review of Day 3
Module 5: Review of Day 3 Andrew Cumming, SoC Bill Buchanan, SoC W.Buchanan (1) Course Outline Day 1: Morning Introduction to Object-Orientation, Introduction to.net, Overview of.net Framework,.NET Components.
More information1. Windows Forms 2. Event-Handling Model 3. Basic Event Handling 4. Control Properties and Layout 5. Labels, TextBoxes and Buttons 6.
C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed
More informationThis is the start of the server code
This is the start of the server code using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Net; using System.Net.Sockets;
More information.NET. Details: Name: Course:.Net XML Web Services Introduction to.net Unit: 0 Instructors: Bill Buchanan/ Alistair Lawson. W.Buchanan/A.
Name: Course:.Net XML Web Services Title: Introduction to.net Unit: 0 Instructors: Bill Buchanan/ Alistair Lawson Details: Login details: Username: lincrea Password: plugtop07 Web page: http:www.dcs.napier.ac.uk/~bill/dotnet_web.htm
More informationTeacher Training Solutions
Teacher Training Solutions Practical 7 Exercise 1 Task 1 class Animal private String name; private String diet; private String location; private double weight; private int age; private String colour; Page
More informationLISTING PROGRAM. //Find the maximum and minimum values in the array int maxvalue = integers[0]; //start with first element int minvalue = integers[0];
1 LISTING PROGRAM using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; namespace SortingApplication static class Program / / The main entry point for
More informationSub To Srt Converter. This is the source code of this program. It is made in C# with.net 2.0.
Sub To Srt Converter This is the source code of this program. It is made in C# with.net 2.0. form1.css /* * Name: Sub to srt converter * Programmer: Paunoiu Alexandru Dumitru * Date: 5.11.2007 * Description:
More informationInheriting Windows Forms with Visual C#.NET
Inheriting Windows Forms with Visual C#.NET Overview In order to understand the power of OOP, consider, for example, form inheritance, a new feature of.net that lets you create a base form that becomes
More informationTutorial 5 Completing the Inventory Application Introducing Programming
1 Tutorial 5 Completing the Inventory Application Introducing Programming Outline 5.1 Test-Driving the Inventory Application 5.2 Introduction to C# Code 5.3 Inserting an Event Handler 5.4 Performing a
More informationListBox. Class ListBoxTest. Allows users to add and remove items from ListBox Uses event handlers to add to, remove from, and clear list
C# cont d (C-sharp) (many of these slides are extracted and adapted from Deitel s book and slides, How to Program in C#. They are provided for CSE3403 students only. Not to be published or publicly distributed
More informationTutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic
Tutorial 6 Enhancing the Inventory Application Introducing Variables, Memory Concepts and Arithmetic Outline 6.1 Test-Driving the Enhanced Inventory Application 6.2 Variables 6.3 Handling the TextChanged
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 Objects and classes: Basics of object and class in C#. Private and public members and protected. Static
More informationIn order to create your proxy classes, we have provided a WSDL file. This can be located at the following URL:
Send SMS via SOAP API Introduction You can seamlessly integrate your applications with aql's outbound SMS messaging service via SOAP using our SOAP API. Sending messages via the SOAP gateway WSDL file
More informationC# and.net (1) cont d
C# and.net (1) cont d Acknowledgements and copyrights: these slides are a result of combination of notes and slides with contributions from: Michael Kiffer, Arthur Bernstein, Philip Lewis, Hanspeter Mφssenbφck,
More informationComputing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects
Computing is about Data Processing (or "number crunching") Object Oriented Programming is about Cooperating Objects C# is fully object-oriented: Everything is an Object: Simple Types, User-Defined Types,
More informationCHAPTER 3. Writing Windows C# Programs. Objects in C#
90 01 pp. 001-09 r5ah.ps 8/1/0 :5 PM Page 9 CHAPTER 3 Writing Windows C# Programs 5 9 Objects in C# The C# language has its roots in C++, Visual Basic, and Java. Both C# and VB.Net use the same libraries
More informationPS2 Random Walk Simulator
PS2 Random Walk Simulator Windows Forms Global data using Singletons ArrayList for storing objects Serialization to Files XML Timers Animation This is a fairly extensive Problem Set with several new concepts.
More informationCSC 330 Object-Oriented Programming. Encapsulation
CSC 330 Object-Oriented Programming Encapsulation Implementing Data Encapsulation using Properties Use C# properties to provide access to data safely data members should be declared private, with public
More informationProgramming using C# LECTURE 07. Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism
Programming using C# LECTURE 07 Inheritance IS-A and HAS-A Relationships Overloading and Overriding Polymorphism What is Inheritance? A relationship between a more general class, called the base class
More informationLecture 4 Overview of Classes, Containers & Generics
Lecture 4 Overview of Classes, Containers & Generics What is a Programming Object? An object is an instance of a class. A class is a template for an object. Everything's an object!!! Statements such as
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Sunday, Tuesday: 9:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming A programming
More informationGetter and Setter Methods
Example 1 namespace ConsoleApplication14 public class Student public int ID; public string Name; public int Passmark = 50; class Program static void Main(string[] args) Student c1 = new Student(); Console.WriteLine("please..enter
More informationLab - 1. Solution : 1. // Building a Simple Console Application. class HelloCsharp. static void Main() System.Console.WriteLine ("Hello from C#.
Lab - 1 Solution : 1 // Building a Simple Console Application class HelloCsharp static void Main() System.Console.WriteLine ("Hello from C#."); Solution: 2 & 3 // Building a WPF Application // Verifying
More informationOsp::Base::Collection
Osp::Base::Collection Contents Collections Interfaces and Enumerators Helpers Lists Maps and MultiMaps Stack and Queue 2 Introduction A collection means an aggregation of similar objects. The collection
More informationTutorial 19 - Microwave Oven Application Building Your Own Classes and Objects
1 Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline 19.1 Test-Driving the Microwave Oven Application 19.2 Designing the Microwave Oven Application 19.3 Adding a New
More informationDistributed Systems Recitation 1. Tamim Jabban
15-440 Distributed Systems Recitation 1 Tamim Jabban Office Hours Office 1004 Tuesday: 9:30-11:59 AM Thursday: 10:30-11:59 AM Appointment: send an e-mail Open door policy Java: Object Oriented Programming
More informationAvoiding KeyStrokes in Windows Applications using C#
Avoiding KeyStrokes in Windows Applications using C# In keeping with the bcrypt.exe example cited elsewhere on this site, we seek a method of avoiding using the keypad to enter pass words and/or phrases.
More informationLISTING PROGRAM. // // TODO: Add constructor code after the InitializeComponent()
A-1 LISTING PROGRAM Form Mainform /* * Created by SharpDevelop. * User: Roni Anggara * Date: 5/17/2016 * Time: 8:52 PM * * To change this template use Tools Options Coding Edit Standard Headers. */ using
More informationUNIT III APPLICATION DEVELOPMENT ON.NET
UNIT III APPLICATION DEVELOPMENT ON.NET Syllabus: Building Windows Applications, Accessing Data with ADO.NET. Creating Skeleton of the Application Select New->Project->Visual C# Projects->Windows Application
More informationCSC330 Object Oriented Programming. Inheritance
CSC330 Object Oriented Programming Inheritance Software Engineering with Inheritance Can customize derived classes to meet needs by: Creating new member variables Creating new methods Override base-class
More informationInheritance and Polymorphism
Object Oriented Programming Designed and Presented by Dr. Ayman Elshenawy Elsefy Dept. of Systems & Computer Eng.. Al-Azhar University Website: eaymanelshenawy.wordpress.com Email : eaymanelshenawy@azhar.edu.eg
More informationConvertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un
Convertor Binar -> Zecimal Rosu Alin, Calculatoare, An2 Mod de Functionare: Am creat un program, in Windows Form Application, care converteste un numar binar, in numar zecimal. Acest program are 4 numericupdown-uri
More informationWeb Services in.net (2)
Web Services in.net (2) These slides are meant to be for teaching purposes only and only for the students that are registered in CSE4413 and should not be published as a book or in any form of commercial
More informationLet s get started! You first need to download Visual Studio to edit, compile and run C# programs. Download the community version, its free.
C# Mini Lessons last update May 15,2018 From http://www.onlineprogramminglessons.com These C# mini lessons will teach you all the C# Programming statements you need to know, so you can write 90% of any
More informationLampiran B. Program pengendali
Lampiran B Program pengendali #pragma once namespace serial using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms;
More informationAdvanced Programming Methods. Lecture 9 - Generics, Collections and IO operations in C#
Advanced Programming Methods Lecture 9 - Generics, Collections and IO operations in C# Content Language C#: 1. Generics 2. Collections 3. IO operations C# GENERICS C# s genericity mechanism, available
More informationconsiders the key aspects of the.net Framework; provides an introduction to C#; gives some examples of some standalone programs written in C#.
A Taste of C# Barry Cornelius Computing Services, University of Oxford Date: 24th February 2002; first created: 11th March 2001 http://users.ox.ac.uk/~barry/papers/ mailto:barry.cornelius@oucs.ox.ac.uk
More informationLangage C# et environnement.net M1 Année
Cahier de TP C# et.net SÉANCE 1 : BASIC OOL CONCEPTS...1 SÉANCE 2 : DELEGATES, EVENTS, THREAD-SAFE CONTROL ACCESS, RESOURCE MANAGEMENT...3 SÉANCE 3 : INHERITANCE, POLYMORPHISM, CONTAINERS, SERIALIZATION...5
More informationObject-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationPolymorphism. Polymorphism. CSC 330 Object Oriented Programming. What is Polymorphism? Why polymorphism? Class-Object to Base-Class.
Polymorphism CSC 0 Object Oriented Programming Polymorphism is considered to be a requirement of any true -oriented programming language (OOPL). Reminder: What are the other two essential elements in OOPL?
More informationObject-Oriented ProgrammingInheritance & Polymorphism
Inheritance Polymorphism Overriding and Overloading Object-Oriented Programming Inheritance & Polymorphism Inf1 :: 2008/09 Inheritance Polymorphism Overriding and Overloading 1 Inheritance Flat Hierarchy
More informationObject Oriented Programming (OOP) is a style of programming that incorporates these 3 features: Encapsulation Polymorphism Class Interaction
Object Oriented Programming (OOP) is a style of programming that incorporates these 3 features: Encapsulation Polymorphism Class Interaction Class Interaction There are 3 types of class interaction. One
More information9 A Preview of.net 2.0
473 9 A Preview of.net 2.0 Microsoft.NET is an evolving system that is continuously improved and extended. In late 2003 Microsoft announced.net 2.0 (codename Whidbey) as a major new version of.net; a beta
More informationnamespace Tst_Form { private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components;
Exercise 9.3 In Form1.h #pragma once #include "Form2.h" Add to the beginning of Form1.h #include #include For srand() s input parameter namespace Tst_Form using namespace System; using
More informationEEE-425 Programming Languages (2013) 1
2 Learn about class concepts How to create a class from which objects can be instantiated Learn about instance variables and methods How to declare objects How to organize your classes Learn about public
More informationCIS 3260 Sample Final Exam Part II
CIS 3260 Sample Final Exam Part II Name You may now use any text or notes you may have. Computers may NOT be used. Vehicle Class VIN Model Exhibit A Make Year (date property/data type) Color (read-only
More informationRelationships Between Real Things CSE 143. Common Relationship Patterns. Employee. Supervisor
CSE 143 Object & Class Relationships Inheritance Reading: Ch. 9, 14 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches dog Dog
More informationSoftware Development (cs2500)
Software Development (cs2500) Lecture 31: Abstract Classes and Methods M.R.C. van Dongen January 12, 2011 Contents 1 Outline 1 2 Abstract Classes 1 3 Abstract Methods 3 4 The Object Class 4 4.1 Overriding
More information2609 : Introduction to C# Programming with Microsoft.NET
2609 : Introduction to C# Programming with Microsoft.NET Introduction In this five-day instructor-led course, developers learn the fundamental skills that are required to design and develop object-oriented
More informationRelationships Between Real Things. CSE 143 Java. Common Relationship Patterns. Composition: "has a" CSE143 Sp Student.
CSE 143 Java Object & Class Relationships Inheritance Reading: Ch. 9, 14 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches
More informationWriting Object Oriented Software with C#
Writing Object Oriented Software with C# C# and OOP C# is designed for the.net Framework The.NET Framework is Object Oriented In C# Your access to the OS is through objects You have the ability to create
More informationCreate a Java project named week10
Objectives of today s lab: Through this lab, students will examine how casting works in Java and learn about Abstract Class and in Java with examples. Create a Java project named week10 Create a package
More information1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides
1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of
More informationRelationships Between Real Things CSC 143. Common Relationship Patterns. Composition: "has a" CSC Employee. Supervisor
CSC 143 Object & Class Relationships Inheritance Reading: Ch. 10, 11 Relationships Between Real Things Man walks dog Dog strains at leash Dog wears collar Man wears hat Girl feeds dog Girl watches dog
More informationUNIT 6: INTERFACES & COLLECTIONS
UNIT 6: INTERFACES & COLLECTIONS DEFINING INTERFACES An interface is a collection of abstract-methods that may be implemented by a given class (in other words, an interface expresses a behavior that a
More information9 Hashtables and Dictionaries
9 Hashtables and Dictionaries Chapter 9 Contax T Concrete Stairs HashTables and Dictionaries Learning Objectives Describe the purpose and use of a hashtable Describe the purpose and use of a dictionary
More informationOperatii pop si push-stiva
Operatii pop si push-stiva Aplicatia realizata in Microsoft Visual Studio C++ 2010 permite simularea operatiilor de introducere si extragere a elementelor dintr-o structura de tip stiva.pentru aceasta
More informationObject Orientated Programming Details COMP360
Object Orientated Programming Details COMP360 The ancestor of every action is a thought. Ralph Waldo Emerson Three Pillars of OO Programming Inheritance Encapsulation Polymorphism Inheritance Inheritance
More informationEquality in.net. Gregory Adam 07/12/2008. This article describes how equality works in.net
Equality in.net Gregory Adam 07/12/2008 This article describes how equality works in.net Introduction How is equality implemented in.net? This is a summary of how it works. Object.Equals() Object.Equals()
More informationObject Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name:
Object Oriented Design Final Exam (From 3:30 pm to 4:45 pm) Name: Section 1 Multiple Choice Questions (40 pts total, 2 pts each): Q1: Employee is a base class and HourlyWorker is a derived class, with
More informationThis exam is open book. Each question is worth 3 points.
This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or
More informationInheritance. Software Engineering with Inheritance. CSC330 Object Oriented Programming. Base Classes and Derived Classes. Class Relationships I
CSC0 Object Oriented Programming Inheritance Software Engineering with Inheritance Can customize derived classes to meet needs by: Creating new member variables Creating new methods Override base-class
More informationDOT NET SYLLABUS FOR 6 MONTHS
DOT NET SYLLABUS FOR 6 MONTHS INTRODUCTION TO.NET Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate
More informationFramework Fundamentals
Questions Framework Fundamentals 1. Which of the following are value types? (Choose all that apply.) A. Decimal B. String C. System.Drawing.Point D. Integer 2. Which is the correct declaration for a nullable
More informationUka Tarsadia University MCA ( 3rd Semester)/M.Sc.(CA) (1st Semester) Course : / Visual Programming Question Bank
Unit 1 Introduction to.net Platform Q: 1 Answer in short. 1. Which three main components are available in.net framework? 2. List any two new features added in.net framework 4.0 which is not available in
More informationCALCULATOR APPLICATION
CALCULATOR APPLICATION Form1.cs using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
More informationDepartment of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book
1 Department of Networks College of Bardarash Technical Institute DUHOK Polytechnic University Subject: Programming Fundamental by JAVA Course Book Year 1 Lecturer's name: MSc. Sami Hussein Ismael Academic
More informationINHERITANCE: EXTENDING CLASSES
INHERITANCE: EXTENDING CLASSES INTRODUCTION TO CODE REUSE In Object Oriented Programming, code reuse is a central feature. In fact, we can reuse the code written in a class in another class by either of
More informationIntroduction To C#.NET
Introduction To C#.NET Microsoft.Net was formerly known as Next Generation Windows Services(NGWS).It is a completely new platform for developing the next generation of windows/web applications. However
More informationPES INSTITUTE OF TECHNOLOGY (BSC) V MCA, Second IA Test, September 2014
PES INSTITUTE OF TECHNOLOGY (BSC) V MCA, Second IA Test, September 2014 Topics in Enterprise Architectures-II Solution Set Faculty: Jeny Jijo 1) What is Encapsulation? Explain the two ways of enforcing
More informationAdvanced Object-Oriented Programming. 11 Features. C# Programming: From Problem Analysis to Program Design. 4th Edition
11 Features Advanced Object-Oriented Programming C# Programming: From Problem Analysis to Program Design C# Programming: From Problem Analysis to Program Design 1 4th Edition Chapter Objectives Learn the
More informationJava Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding
Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance
More informationJava Programming. MSc Induction Tutorials Stefan Stafrace PhD Student Department of Computing
Java Programming MSc Induction Tutorials 2011 Stefan Stafrace PhD Student Department of Computing s.stafrace@surrey.ac.uk 1 Tutorial Objectives This is an example based tutorial for students who want to
More informationObject Oriented Programming
Object Oriented Programming Digital Urban Visualization. People as Flows. 10.10.2016 ia zuend@arch.ethz.ch treyer@arch.ethz.ch chirkin@arch.ethz.ch Object Oriented Programming? Pertaining to a technique
More informationCSCI 136 Data Structures & Advanced Programming. Lecture 3 Fall 2018 Instructors: Bill & Bill
CSCI 136 Data Structures & Advanced Programming Lecture 3 Fall 2018 Instructors: Bill & Bill Administrative Details Lab today in TCL 217a (and 216) Lab is due by 11pm Sunday Lab 1 design doc is due at
More information3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.
3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.
More informationDuhok Polytechnic University Amedi Technical Institute/ IT Dept. Halkawt Rajab Hussain
Duhok Polytechnic University Amedi Technical Institute/ IT Dept. By Halkawt Rajab Hussain 2016-04-02 : Structure declaration and initialization. Access to fields of structure. Array of Structs. 11/10/2016
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationYes, this is still a listbox!
Yes, this is still a listbox! Step 1: create a new project I use the beta 2 of Visual Studio 2008 ( codename Orcas ) and Expression Blend 2.0 September preview for this tutorial. You can download the beta2
More informationCS 200 More Classes Jim Williams, PhD
CS 200 More Classes Jim Williams, PhD Week 13 1. Team Lab: Instantiable Class 2. BP2 Milestone 3 Due Thursday 3. P7 Due next Thursday 4. CS 300 Programming II in the future? 5. Lecture: More Classes, UML
More informationCleveland State University. Lecture Notes Feb Iteration Arrays ArrayLists. V. Matos
Cleveland State University IST311 V. Matos Lecture Notes Feb 17-22-24 Iteration Arrays ArrayLists Observe that various ideas discussed in class are given as separate code fragments in one large file. You
More informationFlag Quiz Application
T U T O R I A L 17 Objectives In this tutorial, you will learn to: Create and initialize arrays. Store information in an array. Refer to individual elements of an array. Sort arrays. Use ComboBoxes to
More informationCS313D: ADVANCED PROGRAMMING LANGUAGE
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 7 : Collections Lecture Contents 2 Why collections? What is a collection? Non-generic collections: Array & ArrayList Stack HashTable
More informationThe Microsoft.NET Framework
Microsoft Visual Studio 2005/2008 and the.net Framework The Microsoft.NET Framework The Common Language Runtime Common Language Specification Programming Languages C#, Visual Basic, C++, lots of others
More informationObject-Oriented Programming More Inheritance
Object-Oriented Programming More Inheritance Ewan Klein School of Informatics Inf1 :: 2009/10 Ewan Klein (School of Informatics) OOP: More Inheritance Inf1 :: 2009/10 1 / 45 1 Inheritance Flat Hierarchy
More informationM257 Past Paper Oct 2008 Attempted Solution
M257 Past Paper Oct 2008 Attempted Solution Part 1 Question 1 A version of Java is a particular release of the language, which may be succeeded by subsequent updated versions at a later time. Some examples
More informationCSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community
CSCI-12 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Provide a detailed explanation of what the following code does: 1 public boolean checkstring
More informationXNA 4.0 RPG Tutorials. Part 11b. Game Editors
XNA 4.0 RPG Tutorials Part 11b Game Editors I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of tutorials on
More informationCS1083 Week 2: Arrays, ArrayList
CS1083 Week 2: Arrays, ArrayList mostly review David Bremner 2018-01-08 Arrays (1D) Declaring and using 2D Arrays 2D Array Example ArrayList and Generics Multiple references to an array d o u b l e prices
More information