Read without ads and support Scribd by becoming a Scribd Premium Reader.
 
DRAFT – Please Send Comments toSchuchert@yahoo.comVersion 0.1.142 - 2002-10-22
C# and .NET by Example
Brett L. Schuchert
© 2002 by Brett L. Schuchert
 
DRAFT – Please Send Comments toSchuchert@yahoo.comVersion 0.1.142 - 2002-10-22
© 2002, Brett L. Schuchert i C# and .NET by Example
Table of Contents
 
INTRODUCTION 1
 
W
HY DID
I
START WRITING THIS BOOK 
?...............................................................................................2
 
ITERATION 0: JUMP RIGHT IN 3
 
I
NITIAL
EQUIREMENTS
........................................................................................................................3
 
File: Die.cs 3
 
File: MainApp.cs 3
 
Build & Execute Instructions 4
 
Code Explained 4
 
Initialization 5
 
Constructor Explained 6
 
A Memory Snapshot 6
 
Object Collaboration 7
 
U
SING
D
IE MORE EXTENSIVELY
.............................................................................................................8
 
 New Requirements 8
 
A Memory Snapshot 9
 
Code Explained 10
 
Build & Execute Instructions 11
 
Object Collaboration 12
 
EVIEW
..................................................................................................................................................13
 
Creating classes 13
 
Attributes 13
 
Properties 13
 
Compiling 13
 
Methods & Constructors 13
 
Object Creation 13
 
Sending Messages 14
 
Arrays 14
 
Inheritance 14
 
Using classes in another namespace 14
 
Output 14
 
Overloading 14
 
String Concatenation 14
 
Overriding 14
 
Polymorphism 15
 
ITERATION 1: BOARD GAME 16
 
A
 
P
ROBLEM
...........................................................................................................................................16
 
Examine the domain 16
 
The Static Design 16
 
Changes from Iteration 0 17
 
A Memory Snapshot 18
 
Coding based on dependencies 19
 
Creating the System 19
 
Code Explained 21
 
Object Collaboration 25
 
EVIEW
..................................................................................................................................................26
 
ITERATION 1A: NO NEW FUNCTIONALITY 28
 
N
AMESPACES
.........................................................................................................................................28
 
A Problem 28
 
A Solution 28
 
 
DRAFT – Please Send Comments toSchuchert@yahoo.comVersion 0.1.142 - 2002-10-22
© 2002, Brett L. Schuchert ii C# and .NET by Example
Build & Execute Instructions 29
 
P
ARAMETER 
C
HECKING
.......................................................................................................................29
 
A Problem 29
 
A Solution 29
 
Build & Execute Instructions 30
 
File: Assert.cs 31
 
C
OMMAND
L
INE
P
ARAMETERS
............................................................................................................33
 
A Problem 33
 
A Solution 33
 
Build & Execute Instructions 33
 
 
ITERATION 2: INHERITANCE & POLYMORPHISM 35
 
N
EW
EQUIREMENTS
...........................................................................................................................35
 
B
ACKGROUND
:
 
I
NHERITANCE
&
 
P
OLYMORPHISM
............................................................................36
 
Method and message 36
 
B
UILD
1:
 
A
 
Q
UICK 
S
TART
.....................................................................................................................37
 
Updates to: BoardLocation.cs 37
 
File: StartingLocation.cs 37
 
Updates to: Board.cs 37
 
Updates to: Player.cs 38
 
Updates to: Game.cs 38
 
Build & Execute Instructions 38
 
C
ODE
E
XPLAINED
.................................................................................................................................40
 
Update: BoardLocation.cs 40
 
File: StartingLocation.cs 40
 
Update: Board.cs 42
 
Update: Player.cs 42
 
Update: Game.cs 43
 
Object Collaboration 43
 
B
ACKGROUND
:
 
S
TEPS FOR 
P
OLYMORPHISM
......................................................................................44
 
B
UILD
2:
 
T
HE
EMAINING
C
LASSES
....................................................................................................45
 
File:SurpriseBill.cs 45
 
File: SpringBoard.cs 45
 
File: Board.cs 46
 
Build & Execute Instructions 46
 
C
ODE
E
XPLAINED
.................................................................................................................................46
 
File: SurpriseBill.cs 46
 
File: SpringBoard.cs 47
 
File: Board.cs 47
 
Object Collaboration 48
 
EVIEW
..................................................................................................................................................48
 
Final Observation 50
 
ITERATION 2A: READING FROM A FILE 51
 
T
HE
P
ROBLEM
.......................................................................................................................................51
 
File: BoardLocations.txt 51
 
A
 
S
OLUTION
..........................................................................................................................................51
 
Read lines from a file 52
 
Parse strings into tokens 52
 
Constructing the right kinds of objects 53
 
P
UTTING
I
T
A
LL
T
OGETHER 
................................................................................................................54
 
File: BoardLocationReader.cs 54
 
Changes to: MainApp.cs 55
 
File: BoardLocationReader.cs 56
 
B
UILD
&
 
E
XECUTE
I
NSTRUCTIONS
......................................................................................................58
 
U
SING
B
OARD
L
OCATION
EADER IN
B
OARD
......................................................................................58
 
Update to: Board.cs 58
 
Search History:
Searching...
Result 00 of 00
00 results for result for
  • p.
  • More From This User

    Notes
    Load more