Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 16, 2016
0 parents
commit cb0ed47
Showing
1,456 changed files
with
37,771 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_2.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// 05 - Classes 101\A Simple Class | ||
// copyright 2000 Eric Gunnerson | ||
class VerySimple | ||
{ | ||
int simpleValue = 0; | ||
} | ||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
VerySimple vs = new VerySimple(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 05 - Classes 101\A Simple Class | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
class Point | ||
{ | ||
// constructor | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
// member fields | ||
public int x; | ||
public int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
Console.WriteLine("myPoint.x {0}", myPoint.x); | ||
Console.WriteLine("myPoint.y {0}", myPoint.y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 05 - Classes 101\Member Functions | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
class Point | ||
{ | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
// accessor functions | ||
public int GetX() {return(x);} | ||
public int GetY() {return(y);} | ||
|
||
// variables now private | ||
int x; | ||
int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
Console.WriteLine("myPoint.X {0}", myPoint.GetX()); | ||
Console.WriteLine("myPoint.Y {0}", myPoint.GetY()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 05 - Classes 101\Overloading | ||
// copyright 2000 Eric Gunnerson | ||
class Point | ||
{ | ||
// create a new point from x and y values | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
// create a point from an existing point | ||
public Point(Point p) | ||
{ | ||
this.x = p.x; | ||
this.y = p.y; | ||
} | ||
|
||
int x; | ||
int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
Point mySecondPoint = new Point(myPoint); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_2.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_3.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 05 - Classes 101\Ref and Out Parameters | ||
// copyright 2000 Eric Gunnerson | ||
// error | ||
using System; | ||
class Point | ||
{ | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
// get both values in one function call | ||
public void GetPoint(ref int x, ref int y) | ||
{ | ||
x = this.x; | ||
y = this.y; | ||
} | ||
|
||
int x; | ||
int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
int x; | ||
int y; | ||
|
||
// illegal | ||
myPoint.GetPoint(ref x, ref y); | ||
Console.WriteLine("myPoint({0}, {1})", x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 05 - Classes 101\Ref and Out Parameters | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
class Point | ||
{ | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public void GetPoint(ref int x, ref int y) | ||
{ | ||
x = this.x; | ||
y = this.y; | ||
} | ||
|
||
int x; | ||
int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
int x = 0; | ||
int y = 0; | ||
|
||
myPoint.GetPoint(ref x, ref y); | ||
Console.WriteLine("myPoint({0}, {1})", x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// 05 - Classes 101\Ref and Out Parameters | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
class Point | ||
{ | ||
public Point(int x, int y) | ||
{ | ||
this.x = x; | ||
this.y = y; | ||
} | ||
|
||
public void GetPoint(out int x, out int y) | ||
{ | ||
x = this.x; | ||
y = this.y; | ||
} | ||
|
||
int x; | ||
int y; | ||
} | ||
|
||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Point myPoint = new Point(10, 15); | ||
int x; | ||
int y; | ||
|
||
myPoint.GetPoint(out x, out y); | ||
Console.WriteLine("myPoint({0}, {1})", x, y); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_2.cs |
49 changes: 49 additions & 0 deletions
49
04 - Base Classes and Inheritance/Abstract Classes/File_1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// 06 - Base Classes and Inheritance\Abstract Classes | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
class Engineer | ||
{ | ||
public Engineer(string name, float billingRate) | ||
{ | ||
this.name = name; | ||
this.billingRate = billingRate; | ||
} | ||
|
||
virtual public float CalculateCharge(float hours) | ||
{ | ||
return(hours * billingRate); | ||
} | ||
|
||
virtual public string TypeName() | ||
{ | ||
return("Engineer"); | ||
} | ||
|
||
private string name; | ||
protected float billingRate; | ||
} | ||
class ChemicalEngineer: Engineer | ||
{ | ||
public ChemicalEngineer(string name, float billingRate) : | ||
base(name, billingRate) | ||
{ | ||
} | ||
|
||
// overrides mistakenly omitted | ||
} | ||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Engineer[] earray = new Engineer[2]; | ||
earray[0] = new Engineer("George", 15.50F); | ||
earray[1] = new ChemicalEngineer("Dr. Curie", 45.50F); | ||
|
||
Console.WriteLine("{0} charge = {1}", | ||
earray[0].TypeName(), | ||
earray[0].CalculateCharge(2F)); | ||
Console.WriteLine("{0} charge = {1}", | ||
earray[1].TypeName(), | ||
earray[1].CalculateCharge(0.75F)); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
04 - Base Classes and Inheritance/Abstract Classes/File_2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// 06 - Base Classes and Inheritance\Abstract Classes | ||
// copyright 2000 Eric Gunnerson | ||
using System; | ||
abstract class Engineer | ||
{ | ||
public Engineer(string name, float billingRate) | ||
{ | ||
this.name = name; | ||
this.billingRate = billingRate; | ||
} | ||
|
||
virtual public float CalculateCharge(float hours) | ||
{ | ||
return(hours * billingRate); | ||
} | ||
|
||
abstract public string TypeName(); | ||
|
||
private string name; | ||
protected float billingRate; | ||
} | ||
|
||
class CivilEngineer: Engineer | ||
{ | ||
public CivilEngineer(string name, float billingRate) : | ||
base(name, billingRate) | ||
{ | ||
} | ||
|
||
override public float CalculateCharge(float hours) | ||
{ | ||
if (hours < 1.0F) | ||
hours = 1.0F; // minimum charge. | ||
return(hours * billingRate); | ||
} | ||
|
||
// This override is required, or an error is generated. | ||
override public string TypeName() | ||
{ | ||
return("Civil Engineer"); | ||
} | ||
} | ||
|
||
class ChemicalEngineer: Engineer | ||
{ | ||
public ChemicalEngineer(string name, float billingRate) : | ||
base(name, billingRate) | ||
{ | ||
} | ||
|
||
override public string TypeName() | ||
{ | ||
return("Chemical Engineer"); | ||
} | ||
} | ||
class Test | ||
{ | ||
public static void Main() | ||
{ | ||
Engineer[] earray = new Engineer[2]; | ||
earray[0] = new CivilEngineer("Sir John", 40.0F); | ||
earray[1] = new ChemicalEngineer("Dr. Curie", 45.0F); | ||
|
||
Console.WriteLine("{0} charge = {1}", | ||
earray[0].TypeName(), | ||
earray[0].CalculateCharge(2F)); | ||
Console.WriteLine("{0} charge = {1}", | ||
earray[1].TypeName(), | ||
earray[1].CalculateCharge(0.75F)); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
04 - Base Classes and Inheritance/Arrays of Engineers/Build1.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_1.cs |
1 change: 1 addition & 0 deletions
1
04 - Base Classes and Inheritance/Arrays of Engineers/Build3.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
csc File_3.cs |
Oops, something went wrong.