Você está na página 1de 4

C# code 1. Access the Flower.cs file 2.

To create some enumerations, change the file as follows:


System; System.Collections.Generic; System.Linq; System.Text;

ing ing ing ing

mespace FlowerShop1 public enum FlowerType { Roses = 1, Lilies, Daisies, Carnations, LivePlant, Mixed } public enum FlowerColor { Red = 1, White, Yellow, Pink, Orange, Blue, Lavender, Mixed } public enum FlowerArrangement { Bouquet = 1, Vase, Basket, Mixed } public class Flower { public FlowerType typeOfFlower; public FlowerColor majorColor; public FlowerArrangement arrangement; public decimal unitPrice; public Flower() { typeOfFlower = FlowerType.Mixed; majorColor = FlowerColor.Mixed; arrangement = FlowerArrangement.Vase; unitPrice = 0.00M; } public Flower(FlowerType type) {

typeOfFlower = type; majorColor = FlowerColor.Mixed; arrangement = FlowerArrangement.Vase; unitPrice = 0.00M; } public Flower(FlowerType type, FlowerColor color, FlowerArrangement argn, decimal price) { typeOfFlower = type; majorColor = color; arrangement = argn; unitPrice = price; }

3. Access the FlowerShop.cs file 4. To use the enumerations, change the file as follows:

ing System; ing FlowerShop1;

blic class Program private static OrderProcessing CreateFlowerOrder() { OrderProcessing order = new OrderProcessing(); int type, color, qty; int arrangement; decimal price; Console.WriteLine("======================="); Console.WriteLine("==-=-=Flower Shop=-=-=="); Console.WriteLine("-----------------------"); Console.WriteLine("Enter the Type of Flower Order"); Console.WriteLine("1. Roses"); Console.WriteLine("2. Lilies"); Console.WriteLine("3. Daisies"); Console.WriteLine("4. Carnations"); Console.WriteLine("5. Live Plant"); Console.WriteLine("6. Mixed"); Console.Write("Your Choice: "); type = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the Color"); Console.WriteLine("1. Red"); Console.WriteLine("2. White"); Console.WriteLine("3. Yellow"); Console.WriteLine("4. Pink"); Console.WriteLine("5. Orange"); Console.WriteLine("6. Blue"); Console.WriteLine("7. Lavender"); Console.WriteLine("8. Mixed"); Console.Write("Your Choice: "); color = int.Parse(Console.ReadLine()); Console.WriteLine("Enter the Type of Arrangement");

Console.WriteLine("1. Bouquet"); Console.WriteLine("2. Vase"); Console.WriteLine("3. Basket"); Console.WriteLine("4. Mixed"); Console.Write("Your Choice: "); arrangement = int.Parse(Console.ReadLine()); Console.Write("Enter the Unit Price: "); price = decimal.Parse(Console.ReadLine()); Console.Write("Enter Quantity: "); qty = int.Parse(Console.ReadLine()); Flower flr = new Flower((FlowerType)type, (FlowerColor)color, (FlowerArrangement)arrangement, price); order.flowerOrder = flr; order.quantity = qty; } return order;

private static void ShowFlowerOrder(OrderProcessing order) { Console.WriteLine("======================="); Console.WriteLine("==-=-=Flower Shop=-=-=="); Console.WriteLine("-----------------------"); Console.WriteLine("Flower Type: {0}", order.flowerOrder.typeOfFlower); Console.WriteLine("Flower Color: {0}", order.flowerOrder.majorColor); Console.WriteLine("Arrangement: {0}", order.flowerOrder.arrangement); Console.WriteLine("Price: {0:C}", order.flowerOrder.unitPrice); Console.WriteLine("Quantity: {0}", order.quantity); Console.WriteLine("Total Price: {0:C}", order.GetTotalPrice()); Console.WriteLine("======================="); } public static int Main() { Console.Title = "Corner Stone Flower Shop"; OrderProcessing flower = CreateFlowerOrder(); Console.WriteLine(); Console.Clear(); ShowFlowerOrder(flower); System.Console.ReadKey(); return 0;

5. To execute the application, press Ctrl + F5 or, on the main menu, click Debug -> Build Without Debuggin. Here is an example

===================== -=-=Flower Shop=-=-== --------------------ter the Type of Flower Order

Roses Lilies Daisies Carnations Live Plant Mixed ur Choice: 5 ter the Color Red White Yellow Pink Orange Blue Lavender Mixed ur Choice: 7 ter the Type of Arrangement Bouquet Vase Basket Mixed ur Choice: 3 ter the Unit Price: 35.95 ter Quantity: 4

6. Press Enter

===================== -=-=Flower Shop=-=-== --------------------ower Type: LivePlant ower Color: Lavender rangement: Basket ice: $35.95 antity: 4 tal Price: $143.80 =====================

7. Close the DOS window and return to your programming environment

Você também pode gostar