2.1 program design with silverlight

Upload: marcecullen

Post on 04-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 2.1 Program Design With Silverlight

    1/52

    Session 2.1

  • 7/29/2019 2.1 Program Design With Silverlight

    2/52

  • 7/29/2019 2.1 Program Design With Silverlight

    3/52

    Windows Phone

    3

  • 7/29/2019 2.1 Program Design With Silverlight

    4/52

    Windows Phone

    4

  • 7/29/2019 2.1 Program Design With Silverlight

    5/52

    Windows Phone

    5

  • 7/29/2019 2.1 Program Design With Silverlight

    6/52

    Windows Phone

    6

  • 7/29/2019 2.1 Program Design With Silverlight

    7/52

    Windows Phone

    7

  • 7/29/2019 2.1 Program Design With Silverlight

    8/52

    Windows Phone

    8

  • 7/29/2019 2.1 Program Design With Silverlight

    9/52

    Windows Phone

    9

  • 7/29/2019 2.1 Program Design With Silverlight

    10/52

    Windows Phone

    10

  • 7/29/2019 2.1 Program Design With Silverlight

    11/52

    Windows Phone

    11

  • 7/29/2019 2.1 Program Design With Silverlight

    12/52

    Windows Phone12

    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

    }

  • 7/29/2019 2.1 Program Design With Silverlight

    13/52

    Windows Phone13

    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

  • 7/29/2019 2.1 Program Design With Silverlight

    14/52

    Windows Phone14

    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

  • 7/29/2019 2.1 Program Design With Silverlight

    15/52

    Windows Phone

    15

    Account rob = new Account();rob.SetName("Rob");

  • 7/29/2019 2.1 Program Design With Silverlight

    16/52

    Windows Phone

    16

  • 7/29/2019 2.1 Program Design With Silverlight

    17/52

    Windows Phone

    17

  • 7/29/2019 2.1 Program Design With Silverlight

    18/52

    Windows Phone

    18

  • 7/29/2019 2.1 Program Design With Silverlight

    19/52

    Windows Phone

    19

  • 7/29/2019 2.1 Program Design With Silverlight

    20/52

    Windows Phone

    20

  • 7/29/2019 2.1 Program Design With Silverlight

    21/52

    Windows Phone

    21

  • 7/29/2019 2.1 Program Design With Silverlight

    22/52

    Windows Phone

    22

  • 7/29/2019 2.1 Program Design With Silverlight

    23/52

    Windows Phone

    23

    FrameworkElement

    TextBlock

    TextBox ContentControl

    ButtonBase

    Button

    Control

  • 7/29/2019 2.1 Program Design With Silverlight

    24/52

    Windows Phone

    24

  • 7/29/2019 2.1 Program Design With Silverlight

    25/52

    Windows Phone

    25

  • 7/29/2019 2.1 Program Design With Silverlight

    26/52

    Windows Phone

    26

  • 7/29/2019 2.1 Program Design With Silverlight

    27/52

    Windows Phone

    27

  • 7/29/2019 2.1 Program Design With Silverlight

    28/52

    Windows Phone

    Demo 1: Adding display elementsDemo

    28

  • 7/29/2019 2.1 Program Design With Silverlight

    29/52

    Windows Phone

    29

  • 7/29/2019 2.1 Program Design With Silverlight

    30/52

    Windows Phone

    30

  • 7/29/2019 2.1 Program Design With Silverlight

    31/52

    Windows Phone

    31

  • 7/29/2019 2.1 Program Design With Silverlight

    32/52

    Windows Phone

    32

  • 7/29/2019 2.1 Program Design With Silverlight

    33/52

    Windows Phone

    Demo 2: Display element namesDemo

    33

  • 7/29/2019 2.1 Program Design With Silverlight

    34/52

    Windows Phone

    34

  • 7/29/2019 2.1 Program Design With Silverlight

    35/52

    Windows Phone

  • 7/29/2019 2.1 Program Design With Silverlight

    36/52

    Windows Phone

    private

    public

  • 7/29/2019 2.1 Program Design With Silverlight

    37/52

    Windows Phone

    Account

    Account

  • 7/29/2019 2.1 Program Design With Silverlight

    38/52

    Windows Phone

  • 7/29/2019 2.1 Program Design With Silverlight

    39/52

    Windows Phone

    privateAccount

    public class Account{

    private int age;

    /// rest of account here

    }

  • 7/29/2019 2.1 Program Design With Silverlight

    40/52

    Windows Phone

    publicclassAccount{

    privateint age;

    publicint GetAge()

    {

    returnthis.age;

    }

    publicvoid SetAge( int inAge )

    {

    if ( (inAge > 0) && (inAge < 120) )

    {

    this.age = inAge;

    }

    }

    }

  • 7/29/2019 2.1 Program Design With Silverlight

    41/52

    Windows Phone

    CurrentAccount a = new Account();

    a.SetAge(21);

  • 7/29/2019 2.1 Program Design With Silverlight

    42/52

    Windows Phone

  • 7/29/2019 2.1 Program Design With Silverlight

    43/52

    Windows Phone

  • 7/29/2019 2.1 Program Design With Silverlight

    44/52

    Windows Phone

    publicclassAccount

    {

    privateint ageValue;

    publicint Age

    {

    set

    { if ( (value > 8) && (value < 100) )

    ageValue = value;

    }

    get

    {

    return ageValue;}

    }

    }

  • 7/29/2019 2.1 Program Design With Silverlight

    45/52

    Windows Phone

    get

    set

    value

  • 7/29/2019 2.1 Program Design With Silverlight

    46/52

    Windows Phone

    Account s = newAccount ();s.Age = 21;

    Console.WriteLine ( "Age is : " + s.Age );

  • 7/29/2019 2.1 Program Design With Silverlight

    47/52

    Windows Phone

    Account s = newAccount ();int newAge = 150;

    s.Age = newAge;

    if (s.Age != newAge )

    Console.WriteLine ( "Age was not set" );

  • 7/29/2019 2.1 Program Design With Silverlight

    48/52

    Windows Phone

    get

    publicint AgeInMonths{

    get

    {

    returnthis.ageValue*12;

    }

    }

  • 7/29/2019 2.1 Program Design With Silverlight

    49/52

    Windows Phone

    49

  • 7/29/2019 2.1 Program Design With Silverlight

    50/52

    Windows Phone

    set

    50

  • 7/29/2019 2.1 Program Design With Silverlight

    51/52

    Windows Phone

    51

  • 7/29/2019 2.1 Program Design With Silverlight

    52/52