Click here to Skip to main content
16,005,162 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to update exe file after install application Pin
Ravi Bhavnani23-May-08 18:19
professionalRavi Bhavnani23-May-08 18:19 
QuestionAbout "Cell Change" event in Excel Pin
Mushtaque Nizamani23-May-08 16:32
Mushtaque Nizamani23-May-08 16:32 
QuestionWindows file metadata Pin
asgardh23-May-08 15:13
asgardh23-May-08 15:13 
QuestionAbstract Classes and Interfaces Pin
Jacob Dixon23-May-08 13:31
Jacob Dixon23-May-08 13:31 
AnswerRe: Abstract Classes and Interfaces Pin
Anthony Mushrow23-May-08 14:00
professionalAnthony Mushrow23-May-08 14:00 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon23-May-08 14:22
Jacob Dixon23-May-08 14:22 
GeneralRe: Abstract Classes and Interfaces Pin
Anthony Mushrow23-May-08 14:33
professionalAnthony Mushrow23-May-08 14:33 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon23-May-08 14:39
Jacob Dixon23-May-08 14:39 
I got it to work! Thanks.. let me know what you think about this:
Ok tell me if I am wrong but as you said you do protected string so Dog and Cat have access to it. Now pass the information to Dog() and Cat(). which sets the values for _WhatAmI and _WhatIsMyName in the abstract class Animal. which returns the value for output.. correct?
namespace IT274_U2
{
    public interface IAnimal
    {
        string WhatAmI { get; }
        string WhatIsMyName { get; }
    }

    abstract class Animal : IAnimal
    {
        protected string _WhatAmI;
        protected string _WhatIsMyName;

        public string WhatAmI
        {
            get
            {
                return _WhatAmI;
            }
            set
            {
                _WhatAmI = value;
            }
        }
        public string WhatIsMyName
        {
            get
            {
                return _WhatIsMyName;
            }
            set
            {
                _WhatIsMyName = value;
            }
        }
    }

    class Dog : Animal
    {
        public Dog(string WhatAmI, string WhatIsMyName)
        {
            _WhatAmI = WhatAmI;
            _WhatIsMyName = WhatIsMyName;
        }
        

      }

    class Cat : Animal
    {
        public Cat(string WhatAmI, string WhatIsMyName)
        {
            _WhatAmI = WhatAmI;
            _WhatIsMyName = WhatIsMyName;
        }
    }

    public class TesterClass
    {
        static void DescribeAnimal(IAnimal animal)
        {
            Console.WriteLine("My name is {0}, I am a {1}", animal.WhatIsMyName, animal.WhatAmI);
        }

        static void Main(string[] args)
        {
            Dog mydog = new Dog("Dog", "Spot");
            Cat mycat = new Cat("Cat", "Felix");
            DescribeAnimal(mydog);
            DescribeAnimal(mycat);
            Console.ReadKey();
        }
    }
}

GeneralRe: Abstract Classes and Interfaces [modified] Pin
Roger Alsing23-May-08 23:10
Roger Alsing23-May-08 23:10 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon24-May-08 5:34
Jacob Dixon24-May-08 5:34 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon24-May-08 6:04
Jacob Dixon24-May-08 6:04 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon24-May-08 6:10
Jacob Dixon24-May-08 6:10 
AnswerRe: Abstract Classes and Interfaces Pin
PIEBALDconsult23-May-08 18:43
mvePIEBALDconsult23-May-08 18:43 
GeneralRe: Abstract Classes and Interfaces Pin
Jacob Dixon24-May-08 5:23
Jacob Dixon24-May-08 5:23 
QuestionLog reader, generating events from recorded timestamp Pin
GuimaSun23-May-08 13:18
GuimaSun23-May-08 13:18 
QuestionHow to remove Duplicated rows from DataTable ? Pin
hdv21223-May-08 12:03
hdv21223-May-08 12:03 
AnswerRe: How to remove Duplicated rows from DataTable ? Pin
Christian Graus23-May-08 12:12
protectorChristian Graus23-May-08 12:12 
GeneralRe: How to remove Duplicated rows from DataTable ? Pin
hdv21223-May-08 12:14
hdv21223-May-08 12:14 
GeneralRe: How to remove Duplicated rows from DataTable ? Pin
Christian Graus23-May-08 12:28
protectorChristian Graus23-May-08 12:28 
GeneralRe: How to remove Duplicated rows from DataTable ? Pin
hdv21223-May-08 12:31
hdv21223-May-08 12:31 
QuestionConnect to biometric device Pin
Krazy Programmer23-May-08 7:38
Krazy Programmer23-May-08 7:38 
AnswerRe: Connect to biometric device Pin
led mike23-May-08 8:14
led mike23-May-08 8:14 
AnswerRe: Connect to biometric device Pin
carbon_golem23-May-08 9:03
carbon_golem23-May-08 9:03 
AnswerRe: Connect to biometric device Pin
Thomas Stockwell23-May-08 9:59
professionalThomas Stockwell23-May-08 9:59 
GeneralRe: Connect to biometric device Pin
Krazy Programmer23-May-08 20:42
Krazy Programmer23-May-08 20:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.