Create a class named HousePlant. A HousePlant has fi elds for
a name (for example, "Philodendron"), a price (for example,
29.99), and a value indicating whether the plant has been
fed in the last month (for example, true). Include properties
that contain get and set accessors for each fi eld. Create
a class named DisplayHousePlants that instantiates three
HousePlant objects. Demonstrate the use of each property for
each object. Save the fi le as DisplayHousePlants.cs.
This is what I have done
namespace DisplayHousePlants
{
class HousePlant
{
string plantName;
double plantPrice;
bool fed;
public string PlantName
{
get
{
return plantName;
}
set
{
plantName = value;
}
}
public double PlantPrice
{
get
{
return plantPrice;
}
set
{
plantPrice = value;
}
}
public bool Fed
{
get
{
return fed;
}
set
{
fed = value;
}
}
}
*************************************************************
namespace DisplayHousePlants
{
class DisplayHousePlants
{
public void FlowerMessage(string[] args)
{
HousePlant flower1 = new HousePlant();
flower1.PlantName = "Jelly Bean Plant";
flower1.PlantPrice = 12.99;
flower1.Fed = true;
HousePlant flower2 = new HousePlant();
flower2.PlantName = "Bonsai";
flower2.PlantPrice = 39.99;
flower2.Fed = true;
HousePlant flower3 = new HousePlant();
flower3.PlantName = "Aloe";
flower3.PlantPrice = 9.99;
flower3.Fed = false;
}
}
But I don't know how to display what I have in DisplayHousePlant class........... How do i get it to display?
Loading
VulpesPosted Jan 21, 2012, 6:25 PM
VulpesPosted Jan 22, 2012, 5:29 AM
Prime bPosted Jan 21, 2012, 7:50 PM