Create a class named GirlScout that contains fi elds for a
GirlScout's name, troop number, and dues owed. Include
a constant static fi eld that contains the last words of the
GirlScout motto ("to obey the Girl Scout law"). Include
overloaded constructors that allow you to set all three nonstatic
GirlScout fi elds to default values or to parameter
values. Also include properties for each fi eld. Create a class
named DemoScouts that instantiates two GirlScout objects
and displays their values. Create one object to use the default
constructor and the other to use the constructor that requires
arguments. Also display the GirlScout motto.
This is what I have done so far ( something tells me its completely wrong).
class GirlScout
{
string girlName;
int troopNumber;
double duesOwed;
static const string GIRL_SCOUT_MOTTO = "to obey the Girl Scout Law";
public GirlScout()
{
}
public GirlScout(string name)
{
girlName = name;
}
public GirlScout(int number)
{
troopNumber = number;
}
public GirlScout(double dues)
{
duesOwed = dues;
}
}
****************************
class DemoClass
{
GirlScout girl1 = new GirlScout(2);
GirlScout girl2 = new GirlScout(2.25);
static void Main(string[] args)
{
}
Loading
VulpesPosted Feb 2, 2012, 4:56 AM
Also the question isn't particularly clear.
Reading it as a whole, I think you need to create just 2 overloaded constructors: one that takes no parameters and the other that takes all three. It's not immediately clear what are sensible default values for girl scouts but I've made a stab at it.
Secondly, there's no such thing as a constant static field in C# - you can either declare a field to be 'const' (which is implicitly static or 'static readonly'. For literal strings, I prefer the former.
Anyway, here's my attempt at completing the program: