//assume you know how to obtain user entered data static void Main(string[] args) { double height = 6.5; double width = 8.0; double linearlength = 135.0; string style = "Neighbour Friendly: Spruce"; double price = 108.00; //store the fence area //declare a storage area for the fence data //create a non-static instance of a class //use the new command to create the class instance //the new command references the class constructor FencePanel fenceinfo = new FencePanel(height, width, style, price); //obtain and store gate data FenceGate gateInfo; List <FenceGate> gateList = new List <FenceGate>(); //assume looping to obtain all gate data //each loop is one gate //pass 1 gateInfo = new FenceGate(); //system constructor since Gate has no constructors height = 6.25; width = 4.0; style = "Neighbour Friendly 1/2 Picket: Spruce"; price = 86.45; gateInfo.Height = height; gateInfo.Width = width; gateInfo.Style = style; gateInfo.Price = price; gateList.Add(gateInfo); //pass 2 gateInfo = new FenceGate(); //system constructor since Gate has no constructors height = 6.25; width = 4.0; style = "Neighbour Friendly: Spruce"; price = 86.45; //name of the instance, the dotoperator (the period), the property = value gateInfo.Height = height; gateInfo.Width = width; gateInfo.Style = style; gateInfo.Price = price; gateList.Add(gateInfo); //assume end of gate looping //create the estimate Estimate theEstimate = new Estimate(); //class default constructor theEstimate.LinearLength = linearlength; theEstimate.Panel = fenceinfo; theEstimate.Gates = gateList; //name of the instance, the . and the behavior(method) name theEstimate.CalculatePrice(); //client wishes a output of the estimate //both ways below is correct, just depends which one you want Console.WriteLine("The fence is to be a " + theEstimate.Panel.Style + " style"); Console.WriteLine("Total linear length requested {0}", theEstimate.LinearLength); Console.WriteLine("Number of required panels: {0}", theEstimate.Panel.EstimatedNumberOfPanels(linearlength)); //.count lets you count the number of instances inside Gates Console.WriteLine("Number of gates: {0}", theEstimate.Gates.Count); double fenceArea = theEstimate.Panel.FenceArea(theEstimate.LinearLength); foreach (var item in theEstimate.Gates) { fenceArea += item.GateArea(); } Console.WriteLine(string.Format("total fence surface area {0:0.00}", fenceArea * 2)); Console.ReadKey(); }
//assuming you kno whow to obtain user entered data static void Main(string[] args) { double height = 6.5; double width = 8.0; double linerarlength = 135.0; string style = "neighboor fiendly: spruce"; double price = 108.00; //store panel data //declare storage area for fence data //create a non static instace of a class //use the new command to create the class instance // the new command refererences the class constructor FencePanel panelInfo = new FencePanel(height, width, style, price); //greedy //obtain and store gate data FenceGate gateInfo; List <FenceGate> gateList = new List <FenceGate>(); //Assume looping to obtain all gate data //each loop is one gate //pass 1 height = 6.25; width = 4.0; style = "Neighboor friendly 1/2 picket : spruce"; price = 86.45; gateInfo = new FenceGate(); //default constructor OR system constructor //name of the instance followed by the dot opperator then is followed by the property name gateInfo.GateHeight = height; //set of the property gateInfo.GatePrice = price; gateInfo.GateStyle = style; gateInfo.GateWidth = width; gateList.Add(gateInfo); //Pass 2 height = 6.25; width = 3.0; style = "Neighboor friendly: spruce"; price = 72.95; gateInfo = new FenceGate(height, width, style, price); gateList.Add(gateInfo); //assume end of looping //create estimate Estimate theEstimate = new Estimate(); theEstimate.LinearLength = linerarlength; theEstimate.Panel = panelInfo; theEstimate.Gates = gateList; theEstimate.CalculateTotalPrice(); //client wishes a output of the estimate Console.WriteLine("the fence is to be a " + theEstimate.Panel.Style + " style"); Console.WriteLine("The total cost of the estimate is {0:0.00}", theEstimate.TotalPrice); //get Console.WriteLine("Number of requred panels is {0}", theEstimate.Panel.EstimatedNumberOfPanels(theEstimate.LinearLength)); Console.WriteLine("The number of gates is {0}", theEstimate.Gates.Count); double fenceArea = theEstimate.Panel.TotalArea(theEstimate.LinearLength); foreach (var item in theEstimate.Gates) { fenceArea += item.GateArea(); //item represents a single Gate instance in the colection } Console.WriteLine(string.Format("Total fence surface area {0:0.0}", fenceArea * 2)); Console.ReadLine(); }
// assume you know how to obtain user entered data static void Main(string[] args) { double height = 6.5; double width = 8.0; double linearLength = 135.0; string style = "Neightbour friendly: Spruce"; double price = 108.00; // store the fence data // declare a storage area // create a non static instance of a class // use the new command to create the class instance // the new command references the class constructor FencePanel fenceInfo = new FencePanel(height, width, style, price); // obtain and store gate data FenceGate gateInfo; List <FenceGate> gateList = new List <FenceGate>(); // assuming looping to obtrain all gate data // each loop is one gate // Pass 1 gateInfo = new FenceGate(); // system constructor since FenceGate has no constructors height = 6.25; width = 4.0; style = "Neightbour Freindly 1/2 Picket: Spruce"; price = 86.45; gateInfo.Height = height; gateInfo.Width = width; gateInfo.Style = style; gateInfo.Price = price; // Pass 2 gateInfo = new FenceGate(); // system constructor since FenceGate has no constructors height = 6.25; width = 4.0; style = "Neightbour Freindly: Spruce"; price = 86.45; // name of the instance dot operator the property name = value gateInfo.Height = height; gateInfo.Width = width; gateInfo.Style = style; gateInfo.Price = price; //assume end of looping // create the estimate Estimate theEstimate = new Estimate(); // class default constructor theEstimate.LinearLength = linearLength; theEstimate.Panel = fenceInfo; theEstimate.Gates = gateList; //name of the instance dot operator behaviour name theEstimate.CalculatePrice(); Console.WriteLine("The fence is to be a " + theEstimate.Panel.Style + " style"); Console.WriteLine("Total Linear length requested {0}", theEstimate.LinearLength); Console.WriteLine("Total Linear length requested {0}", theEstimate.Panel.EstimatedNumberOfPanels(theEstimate.LinearLength)); Console.WriteLine("Number of gates: {0}", theEstimate.Gates.Count); double fenceArea = theEstimate.Panel.FenceArea(theEstimate.LinearLength); foreach (var item in theEstimate.Gates) { fenceArea += item.GateArea(); } Console.WriteLine(string.Format("Total fence surface are{0:0.00}", fenceArea * 2)); }