Page 4 of 4 FirstFirst ... 234
Results 31 to 39 of 39
  1. #31

    Default Re: can anyone help with this problem please


    Quote Originally Posted by koujie View Post
    c# program that will show inhertance, encapsulana and polymorphsm
    I'll try to give and example to you. To other members/posters correct me if i got something wrong

    *Inheritance* - by my own understanding, getting the traits of a parent.

    So example:

    class Person
    {
    public string Name { get; set; }
    public int Age { get; set; }
    }

    class Student : Person
    {
    public string School { get; set; }
    }

    Basically you can do this.
    Person person = new Person {;
    Name = "dfd" // or you can also retrieve it.
    Age = 2
    };

    // See the Student class which inherits the Person class, got the properties "Name" and "Age" also.
    Student student = new Student {
    Name = "Ako budoy",
    Age = 21,
    School = "Smart University"
    };

    * Encapsulation * - I think this is hiding or not letting other classes modify the value of an object. Research lang ni TS.
    Example:

    class Person
    {
    private string _typeOfAnimal;
    public string TypeOfAnimal
    {
    get { return _typeOfAnimal; }
    }

    public Person()
    {
    _typeOfAnimal = "Human";
    }

    // for short hand you can do this: public string TypeOfAnimal { get; private set; }
    // Constructor should be like this too: public Person { TypeOfAnimal = "Human"; }
    }

    This class has TypeOfAnimal property in which you can only change its value inside the class. Other class can only get its value but not change it.

    * Polymorphism * a function nga mag usab2x ang buhaton depending on the object nga nagProvide.
    E.g.
    Animals can move.
    Fish moves by swimming.
    Birds moves by flying
    Humans moves by walking
    So moving has is different depending on kinsa ang niMove. so ana pud ang polymorphism.

    E.g.

    interface IAnimal
    {
    void Move();
    }


    class Fish : IAnimal
    {
    public void Move()
    {
    WriteLine("Swim");
    }
    }

    class Bird : IAnimal
    {
    public void Move()
    {
    WriteLine("Fly");
    }
    }

    class Human : IAnimal
    {
    public void Move()
    {
    WriteLine("Walk");
    }
    }

    IAnimal animal = new Human();
    animal.Move(); // should display "walk"
    animal = new Bird();
    animal.Move(); // should display "fly"
    animal = new Fish();
    animal.Move() = // should display "swim"

    So ana..

    Hope this helps.

  2. #32

    Default Re: can anyone help with this problem please

    nice one maikeru...

    OT: Asa ka nga company krn? Hiring pa mo para mkat-on sa imong abilidad hihi

  3. #33

    Default Re: can anyone help with this problem please

    Quote Originally Posted by n00dle$ View Post
    nice one maikeru...

    OT: Asa ka nga company krn? Hiring pa mo para mkat-on sa imong abilidad hihi
    Sa NCR q nagWork ron and yep I think naa hiring karon.

  4. #34

    Default Re: can anyone help with this problem please

    OT: From page 1 up to page 3, nagkatawa ra jud ko

    Bitaw oi, Maikeru already showed the actual implementation sa concepts. Sabta lang gyud ug tarong or better yet, acquire a Java book because naa ra gyud tanan didto.

  5. #35

    Default Re: can anyone help with this problem please

    Quote Originally Posted by Maikeru View Post
    Sa NCR q nagWork ron and yep I think naa hiring karon.
    nice!! former NCR emp sd ko ahehehe

  6. #36

    Default Re: can anyone help with this problem please

    Quote Originally Posted by n00dle$ View Post
    nice!! former NCR emp sd ko ahehehe
    atot diri naman diay ka gkan. hahah

  7. #37

    Default Re: can anyone help with this problem please

    editied because, saup nga thread ang naPostan. sorry

  8. #38
    This is a very intimate topic.

  9. #39
    I am more than sure that this is something very very basic here anyway. IF you already learned something about the things you want to make program in the classroom you should be able to compile something working from the things you got on the lessons, so do not bother people here.

  10.    Advertisement

Page 4 of 4 FirstFirst ... 234

Similar Threads

 
  1. Really need your help with this one please reply ^_^
    By annerhexian in forum General Discussions
    Replies: 12
    Last Post: 03-15-2011, 06:42 PM
  2. Replies: 20
    Last Post: 02-27-2010, 01:39 PM
  3. Problem with my HDD. Can anyone help me?
    By Jason4eveR in forum Computer Hardware
    Replies: 14
    Last Post: 12-08-2009, 01:36 AM
  4. Need help with this problem
    By daddyfree in forum Computer Hardware
    Replies: 14
    Last Post: 10-01-2008, 08:49 AM
  5. Replies: 12
    Last Post: 04-17-2008, 04:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top