Microsoft Visual C# 7th edition. Instruction: Write an application for Nina’s Cookie Emporium named CookieDemo that declares and demonstrates objects of the CookieOrder class and its descendants. The CookieOrder class includes the following auto-implemented properties: OrderNum - The order number Name - The recipient’s name CookieType - The cookie type (for example, chocolate chip) The class should also include fields for number of dozens ordered and price (named Dozens and Price). When the field value for number of dozens ordered is set, the price field is set as $15 per dozen for the first two dozen and $13 per dozen for each dozen over two. Next, create a child class named SpecialCookieOrder, which includes a field with a description as to why the order is special (for example, gluten-free). Override the method that sets a CookieOrder’s price as described in the step above, but also to include special handling, which is $10 for orders up to $40 and $8 for higher-priced orders. An example of the program is shown below: Order #101 Arthur type: gluten-free chocolate chip 1 dozen --- $25 Order #102 Brown type: sugar-free peanut butter 2 dozen --- $40 Order #103 Cooper type: iced sugar 3 dozen --- $51

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Microsoft Visual C# 7th edition.

Instruction: Write an application for Nina’s Cookie Emporium named CookieDemo that declares and demonstrates objects of the CookieOrder class and its descendants. The CookieOrder class includes the following auto-implemented properties:

  • OrderNum - The order number
  • Name - The recipient’s name
  • CookieType - The cookie type (for example, chocolate chip)

The class should also include fields for number of dozens ordered and price (named Dozens and Price). When the field value for number of dozens ordered is set, the price field is set as $15 per dozen for the first two dozen and $13 per dozen for each dozen over two.

Next, create a child class named SpecialCookieOrder, which includes a field with a description as to why the order is special (for example, gluten-free). Override the method that sets a CookieOrder’s price as described in the step above, but also to include special handling, which is $10 for orders up to $40 and $8 for higher-priced orders.

An example of the program is shown below:

Order #101 Arthur type: gluten-free chocolate chip 1 dozen --- $25 Order #102 Brown type: sugar-free peanut butter 2 dozen --- $40 Order #103 Cooper type: iced sugar 3 dozen --- $51

 

 

Here is my code. It gives me an infinite loop.

 

using static System.Console;
class CookieDemo2
{
   static void Main()
   {
     // Your code here
      
     CookieOrder cookieOrder = new CookieOrder();
     cookieOrder.OrderNum = "101";
     cookieOrder.Name = "Arthur";
     cookieOrder.CookieType = "chocolate chip";
     cookieOrder.Dozens = 1;

     SpecialCookieOrder specialCookieOrder= new SpecialCookieOrder();

specialCookieOrder.OrderNum="101";
specialCookieOrder.Name = "Arthur";
specialCookieOrder.CookieType = "chocolate chip";
specialCookieOrder.specialType = "gluten-free";
specialCookieOrder.Dozens= 1;
     
    WriteLine("Order # {0}{1, 4}",cookieOrder.OrderNum,cookieOrder.Name);
     WriteLine("Order # {0}{1, 4}",specialCookieOrder.OrderNum,specialCookieOrder.Name);
     
     WriteLine("type: {0} {1}",specialCookieOrder.specialType,cookieOrder.CookieType);
     WriteLine(cookieOrder.OrderNum + "--- $" + cookieOrder.Price);
   }
}//end CookieDemo2

class CookieOrder
{
  public string OrderNum {get; set;}
  public string Name {get; set;}
  public string CookieType {get; set;}
  private int dozens;
  protected int price;
  //this.price=price;
  //this.dozens=dozens;
  public int Dozens
  {
    get {return dozens;}
    set {dozens = value;}
  }

  public virtual int Price
  {
  get {return Price;}
    set 
    {
      if(Dozens <= 2)
      Price = Dozens * 15;
      else
      if(Dozens > 2)
      Price = Dozens * 13;
    }
  }
}//end class CookieOrder

class SpecialCookieOrder : CookieOrder
{
  public string specialType;
public override int Price
{
  get{return base.Price;}
set {
  if(base.Price < 40)
  base.Price = price;
  else
  if(base.Price <= 40)
  price = price + 10;
  else
  if(price > 40)
  price = price + 8;

}
}
}





 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education