Ok So I have two classes that share the same instance variables, the variables have been declared in 'Dog', however I cannot seem to get the instances to work within my other class 'DogChorus'. Therefore what must I do to get the instances to work within 'DogChorus' constructors?
The variables are:
barkSound
breed
dogHeight
dogColour
Code below that I have used:
DOG
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloDogs
{
class Dog
{
private string barkSound;
private string breed;
private int dogHeight;
private string dogColour;
private static int noOfLEgs;
public string Breed
{
get { return breed; }
set { breed = value; }
}
private string dogSpeech;
public Dog()
{
barkSound = "Woof!";
breed = "cocker spaniel";
dogHeight = 10;
dogColour = "white";
}
public string GetSpeech(int passed_size)
{
if (IsBig(passed_size) == true)
{
dogSpeech = "Hello. I am a " + breed + ". " + barkSound + " I am Big ";
}
else
{
dogSpeech = "Hello. I am a " + breed + ". " + barkSound + " I am small ";
}
return dogSpeech;
}
private void SetSound(String barkSound)
{
this.barkSound = barkSound;
}
private static bool IsBig(int size)
{
{
bool Size1;
if (size < 50)
{
Size1 = false;
}
else
{
Size1 = true;
return Size1;}}}}
DogChorus
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace HelloDogs
{
class DogChorus
{
public DogChorus() {
}
DogChorus(int a) : this(a, "defaultStringValue")
{
barkSound = "Woof!";
breed = "cocker spaniel";
dogHeight = 10;
dogColour = "white";
}
DogChorus(int a, string b)
{
}
public string GetOutput(){
return lady.GetSpeech() + " \n " + tramp.GetSpeech();
}
}