Difference between revisions of "OOP Class6"

esse quam videri
Jump to: navigation, search
(UML)
(UML)
Line 7: Line 7:
  
  
Simple Dog Class from week 5 [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class6/DiagramDog/DogSimple.cs DogSimple.cs - source]
+
Simple Dog Class from week 5 [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class6/DiagramDog/DogSimple.cs DogSimple.cs - source]<br />
 
[[Image:DogSimple.png]]
 
[[Image:DogSimple.png]]
 
<csharp>using System;
 
<csharp>using System;
Line 27: Line 27:
 
//put bark code here
 
//put bark code here
 
}
 
}
 +
public void Eat() {
 +
//put eat code here
 +
}
 +
}</csharp>
 +
 +
 +
Dog UML with Types
 +
 +
Dog Class with Types from week 4 [http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class6/DiagramDog/DogWithTypes.cs DogWithTypes.cs - source]<br /><br />
 +
[[Image:DogWithTypes.png]]
 +
<csharp>using System;
 +
 +
//Dog simple class definition
 +
public class Dog
 +
{
 +
public string Name; // the dog's name
 +
private int Age; // the dog's age
 +
public int Weight; // the dog's weight
 +
public string BarkSound; // the sound of the dog's bark
 +
private int barkCount;    //The number of time the dog has barked
 +
public Dog()
 +
{
 +
BarkSound = "Woof!!!";
 +
}
 +
 +
public string Bark() {
 +
string strBark = this.BarkSound;
 +
        barkCount ++;
 +
        return strBark;
 +
}
 +
   
 
public void Eat() {
 
public void Eat() {
 
//put eat code here  
 
//put eat code here  

Revision as of 17:41, 27 February 2006

UML

Dia A Drawing Program

Dia for windows

[Dog Diagrams with Dia


Simple Dog Class from week 5 DogSimple.cs - source
DogSimple.png <csharp>using System;

//Dog simple class definition public class Dog {

	public string Name;		// the dog's name

public int Age; // the dog's age public int Weight; // the dog's weight public string BarkSound; // the sound of the dog's bark

public Dog() { BarkSound = "Woof!!!"; }

public void Bark() { //put bark code here } public void Eat() { //put eat code here } }</csharp>


Dog UML with Types

Dog Class with Types from week 4 DogWithTypes.cs - source

DogWithTypes.png <csharp>using System;

//Dog simple class definition public class Dog {

	public string Name;		// the dog's name

private int Age; // the dog's age public int Weight; // the dog's weight public string BarkSound; // the sound of the dog's bark private int barkCount; //The number of time the dog has barked public Dog() { BarkSound = "Woof!!!"; }

public string Bark() { string strBark = this.BarkSound;

       barkCount ++;
       return strBark;

}

public void Eat() { //put eat code here } }</csharp>

Interfaces

Interfaces - implements or derives from

An interface is a class that lacks implementation. The only thing it contains are definitions of events, indexers, methods and/or properties. The reason interfaces only provide definitions is because they are inherited by classes and structs, which must provide an implementation for each interface member defined. Since classes in c# can only be derived from one other class ( in c++ it is possible to derive from many) interfaces are used for multiple inheritance. Like abstract classes you cannot create an instance of an interface on derive from it.

/infod/jeff/classSource/class5/interface.cs -source /infod/jeff/classSource/class5/interface2.cs -source Phone interface example phoneIFace.cs -source Multiple interface inheritance - inherits IPhone, Cell, POTS /infod/jeff/classSource/class5/phoneIFacePOTS.cs -source

ArsDigita University Course 04: Object-oriented Program Design and Software Engineering - Lecture Notes 4

ArsDigita University Course 04: Object-oriented Program Design and Software Engineering - Lecture Notes 5