Download - 2.1 Program Design With Silver Light
-
8/4/2019 2.1 Program Design With Silver Light
1/52
-
8/4/2019 2.1 Program Design With Silver Light
2/52
-
8/4/2019 2.1 Program Design With Silver Light
3/52
3
-
8/4/2019 2.1 Program Design With Silver Light
4/52
4
-
8/4/2019 2.1 Program Design With Silver Light
5/52
5
-
8/4/2019 2.1 Program Design With Silver Light
6/52
6
-
8/4/2019 2.1 Program Design With Silver Light
7/52
7
-
8/4/2019 2.1 Program Design With Silver Light
8/52
8
-
8/4/2019 2.1 Program Design With Silver Light
9/52
9
-
8/4/2019 2.1 Program Design With Silver Light
10/52
10
-
8/4/2019 2.1 Program Design With Silver Light
11/52
11
-
8/4/2019 2.1 Program Design With Silver Light
12/52
12
public classAccount
{
private decimal balance ;
private string name ;
public string GetName ()
{
return name;}
public bool SetName (string newName){
{
// Final version will validate the name
name = newName;return true;
}
// Other get and set methods here
}
-
8/4/2019 2.1 Program Design With Silver Light
13/52
13
public classAccount
{
private decimal balance ;
private string name ;
public string GetName ()
{
return name;}
public bool SetName (string newName){
{
// Final version will validate the name
name = newName;return true;
}
// Other get and set methods here
}
This is the data our bank account will hold:The name of the holder and the balance
-
8/4/2019 2.1 Program Design With Silver Light
14/52
14
public classAccount
{
private decimal balance ;
private string name ;
public string GetName ()
{
return name;}
public bool SetName (string newName){
{
// Final version will validate the name
name = newName;return true;
}
// Other get and set methods here
}
These are the behaviours the account provides
-
8/4/2019 2.1 Program Design With Silver Light
15/52
15
Account rob = new Account();rob.SetName("Rob");
-
8/4/2019 2.1 Program Design With Silver Light
16/52
16
-
8/4/2019 2.1 Program Design With Silver Light
17/52
17
-
8/4/2019 2.1 Program Design With Silver Light
18/52
18
-
8/4/2019 2.1 Program Design With Silver Light
19/52
19
-
8/4/2019 2.1 Program Design With Silver Light
20/52
20
-
8/4/2019 2.1 Program Design With Silver Light
21/52
21
-
8/4/2019 2.1 Program Design With Silver Light
22/52
22
-
8/4/2019 2.1 Program Design With Silver Light
23/52
23
FrameworkElement
TextBlock
TextBox ContentControl
ButtonBase
Button
Control
-
8/4/2019 2.1 Program Design With Silver Light
24/52
24
-
8/4/2019 2.1 Program Design With Silver Light
25/52
25
-
8/4/2019 2.1 Program Design With Silver Light
26/52
26
-
8/4/2019 2.1 Program Design With Silver Light
27/52
27
-
8/4/2019 2.1 Program Design With Silver Light
28/52
28
-
8/4/2019 2.1 Program Design With Silver Light
29/52
29
-
8/4/2019 2.1 Program Design With Silver Light
30/52
30
-
8/4/2019 2.1 Program Design With Silver Light
31/52
31
-
8/4/2019 2.1 Program Design With Silver Light
32/52
32
-
8/4/2019 2.1 Program Design With Silver Light
33/52
33
-
8/4/2019 2.1 Program Design With Silver Light
34/52
34
-
8/4/2019 2.1 Program Design With Silver Light
35/52
-
8/4/2019 2.1 Program Design With Silver Light
36/52
private
public
-
8/4/2019 2.1 Program Design With Silver Light
37/52
Account
Account
-
8/4/2019 2.1 Program Design With Silver Light
38/52
-
8/4/2019 2.1 Program Design With Silver Light
39/52
privateAccount
public class Account{
private int age;
/// rest of account here
}
-
8/4/2019 2.1 Program Design With Silver Light
40/52
publicclassAccount{
privateint age;
publicint GetAge()
{
returnthis.age;
}
publicvoid SetAge( int inAge )
{
if ( (inAge > 0) && (inAge < 120) )
{
this.age = inAge;
}
}
}
-
8/4/2019 2.1 Program Design With Silver Light
41/52
CurrentAccount a = new Account();
a.SetAge(21);
-
8/4/2019 2.1 Program Design With Silver Light
42/52
-
8/4/2019 2.1 Program Design With Silver Light
43/52
-
8/4/2019 2.1 Program Design With Silver Light
44/52
publicclassAccount
{
privateint ageValue;
publicint Age
{
set
{ if ( (value > 8) && (value < 100) )
ageValue = value;
}
get
{
return ageValue;}
}
}
-
8/4/2019 2.1 Program Design With Silver Light
45/52
value
-
8/4/2019 2.1 Program Design With Silver Light
46/52
Account s = newAccount ();s.Age = 21;
Console.WriteLine ( "Age is : " + s.Age );
-
8/4/2019 2.1 Program Design With Silver Light
47/52
Account s = newAccount ();int newAge = 150;
s.Age = newAge;
if (s.Age != newAge )
Console.WriteLine ( "Age was not set" );
-
8/4/2019 2.1 Program Design With Silver Light
48/52
publicint AgeInMonths{
get
{
returnthis.ageValue*12;
}
}
-
8/4/2019 2.1 Program Design With Silver Light
49/52
49
-
8/4/2019 2.1 Program Design With Silver Light
50/52
50
-
8/4/2019 2.1 Program Design With Silver Light
51/52
51
-
8/4/2019 2.1 Program Design With Silver Light
52/52