Click here to Skip to main content
15,883,818 members
Home / Discussions / C#
   

C#

 
GeneralRe: LINQ : Unmatched data is coming for inner join Pin
Mou_kol5-Jul-19 10:05
Mou_kol5-Jul-19 10:05 
Questionc# Pin
Member 1312071627-Jun-19 22:49
Member 1312071627-Jun-19 22:49 
AnswerRe: c# Pin
OriginalGriff27-Jun-19 23:30
mveOriginalGriff27-Jun-19 23:30 
GeneralRe: c# Pin
Eddy Vluggen28-Jun-19 2:03
professionalEddy Vluggen28-Jun-19 2:03 
GeneralRe: c# Pin
OriginalGriff28-Jun-19 2:23
mveOriginalGriff28-Jun-19 2:23 
GeneralRe: c# Pin
Eddy Vluggen28-Jun-19 2:39
professionalEddy Vluggen28-Jun-19 2:39 
AnswerRe: c# Pin
Gerry Schmitz28-Jun-19 6:51
mveGerry Schmitz28-Jun-19 6:51 
QuestionBase toString not printing to console Pin
Member 1451443227-Jun-19 5:42
Member 1451443227-Jun-19 5:42 
Hi, I'm practicing polymorphism,
inheritance
and abtraction, my tostring method in the base class isn't printing to the console only the child class

C#
public abstract class Animal
    {
        private String name;
        private int age;
        private String breed;
        private String furColor;

        public Animal(String name,int age,String breed,String furColor)
        {
            this.name = name;
            this.age = age;
            this.breed = breed;
            this.furColor = furColor;
        }

        public void setName(String name)
        {
            this.name = name;
        }

        public String getName()
        {
            return this.name;
        }

        public void setAge(int age)
        {
            this.age = age;
        }

        public int getAge()
        {
            return this.age;
        }

        public void setBreed(String breed)
        {
            this.breed = breed;
        }

        public String getBreed()
        {
            return this.breed;
        }

        public void setFurColor(String furColor)
        {
            this.furColor = furColor;
        }

        public String getFurColor()
        {
            return this.furColor;
        }

        public abstract void sound();

        public string ToStirng()
        {
            return ("Name: " + getName()
                    +"\n"
                    +"Age: " + getAge()
                    +"\n"
                    +"Breed: " + getBreed()
                    +"\n"
                    +"Fur Color: " + getFurColor());
        }
    }


C#
<pre>public class Cat : Animal
    {
        private String favoriteToy;

        public Cat(String name,int age,String breed,String furColor,String favoriteToy):base(name,age,breed,furColor){
            this.favoriteToy = favoriteToy;

        }

        public void setFavoriteToy(String favoriteToy)
        {
            this.favoriteToy = favoriteToy;
                
        }

        public String getFavoriteToy()
        {
            return this.favoriteToy;
        }

        public override void sound()
        {
            Console.WriteLine( getName() + " is a beautiful cat, he is "  + getAge() + " and he likes to Meow."); 
        }

        public override string ToString() => (base.ToString() +
                    "\n"
                   + "Favorite Toy: " + getFavoriteToy());
    }


C#
static void Main(string[] args)
        {
            Cat C = new Cat("Fluffy",4,"Tabby","Ginger","Mouse");
            Console.WriteLine(value: C.ToString());
            C.sound();
        }


its only printing out "Favorite toy" and the sound method, would appreciate any help please.
AnswerRe: Base toString not printing to console Pin
Dave Kreskowiak27-Jun-19 5:59
mveDave Kreskowiak27-Jun-19 5:59 
GeneralRe: Base toString not printing to console Pin
Member 1451443227-Jun-19 6:14
Member 1451443227-Jun-19 6:14 
AnswerRe: Base toString not printing to console Pin
OriginalGriff27-Jun-19 6:07
mveOriginalGriff27-Jun-19 6:07 
GeneralRe: Base toString not printing to console Pin
Member 1451443227-Jun-19 6:12
Member 1451443227-Jun-19 6:12 
GeneralRe: Base toString not printing to console Pin
OriginalGriff27-Jun-19 6:24
mveOriginalGriff27-Jun-19 6:24 
QuestionNew to Coding New to Code Project Pin
Member 1451100824-Jun-19 10:11
Member 1451100824-Jun-19 10:11 
AnswerRe: New to Coding New to Code Project Pin
Eddy Vluggen24-Jun-19 11:19
professionalEddy Vluggen24-Jun-19 11:19 
GeneralRe: New to Coding New to Code Project Pin
Mycroft Holmes24-Jun-19 13:10
professionalMycroft Holmes24-Jun-19 13:10 
GeneralRe: New to Coding New to Code Project Pin
Eddy Vluggen24-Jun-19 13:27
professionalEddy Vluggen24-Jun-19 13:27 
AnswerRe: New to Coding New to Code Project Pin
Mycroft Holmes24-Jun-19 13:11
professionalMycroft Holmes24-Jun-19 13:11 
AnswerRe: New to Coding New to Code Project Pin
Ger Hayden24-Jun-19 21:51
Ger Hayden24-Jun-19 21:51 
AnswerRe: New to Coding New to Code Project Pin
Richard MacCutchan24-Jun-19 22:24
mveRichard MacCutchan24-Jun-19 22:24 
AnswerRe: New to Coding New to Code Project Pin
#realJSOP26-Jun-19 6:32
mve#realJSOP26-Jun-19 6:32 
AnswerRe: New to Coding New to Code Project Pin
Gerry Schmitz26-Jun-19 8:53
mveGerry Schmitz26-Jun-19 8:53 
QuestionWhat is wrong with my code in Visual Studios Pin
Member 1451091724-Jun-19 7:46
Member 1451091724-Jun-19 7:46 
AnswerRe: What is wrong with my code in Visual Studios Pin
Richard Deeming24-Jun-19 8:39
mveRichard Deeming24-Jun-19 8:39 
GeneralRe: What is wrong with my code in Visual Studios Pin
Member 1451091724-Jun-19 9:12
Member 1451091724-Jun-19 9:12 

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.