Question

The Code need to be in C# programming language. could you please leave some explanation notes...

The Code need to be in C# programming language. could you please leave some explanation notes as much as you can? Thank you


Create the following classes in the class library with following attributes:
1. Customer
a. id number – customer’s id number
b. name –the name of the customer
c. address – address of the customer (use structs)
d. telephone number – 10-digit phone number
e. orders – collection (array) of orders Assume that there will be no more than 50 orders per customer
2. Order
a. order id – order identification number
b. customer – customer that made order
c. order time – date the order is made
d. delivery time - date when the order is delivered
e. delivery address – address where order is to be delivered (use structs)
f. cost – cost of the order
g. order type – Possible values are: PhoneOrder, RestaurantOrder
h. items – collection (array) of order items in the order. Assume that there will be no more then 50 items in the order
3. OrderItem
a. Menu item – menu item that is in the order
4. MenuItem
a. name –name of the menu item
b. description – description of the menu item
c. base cost – cost of the item without any extras
Implement all 4 classes and provide the following:
1. Appropriate fields
2. Appropriate properties for the fields making sure the integrity and consistency of the
created objects
3. Appropriate constructors (a minimum of 1 in addition to the default constructor)
4. Method GetInfo() that returns a string with the information contained within the
fields of an instance
5. An id number for customer must be unique
6. An order number for order must be unique
7. Add following methods for the classes:
a. Customer
i. CreateOrder – creates new order for the customer. Make sure the
corresponding properties are updated accordingly
b. Order
i. AddOrderItem – adds the menu item to the order. Make sure that the
object state is correct (Hint: cost).
ii. Deliver - updates the delivery time with current time
iii. Delivered – (property) that is true if the order is delivered.
8. You can add any additional methods that may be needed.
9. In the main() method, test that all class members work correctly. User input is not
needed - use the literal constants. Make sure you use at least one object initializer.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp
{

enum order_type { PhoneOrder, RestaurantOrder }
class Customer
{
private static int count = 0;
public int id_number;
string name;
string address;
string telephone;
public List<Order> orders;

public Customer()
{
id_number = ++count; //increamented each time new Customer obj is created
orders = new List<Order>(50);
}

public Customer(string custname, string addr, string tel)
{
id_number = ++count; //increamented each time new Customer obj is created
orders = new List<Order>(50);

name = custname;
address = addr;
telephone = tel;
}


public bool CreateOrder(Order ord)
{
if (orders.Count <= 50){
orders.Add(ord);
return true;
}
else
return false;
}

public string GetInfo()   //return customer info with his all orders
{
string str;
str = "CustId: " + id_number + " " + name + ", " + address + " Phone:" + telephone;
if (orders.Count > 0)
{
str += "\nOrders";
foreach (Order o in orders) //get all orders info of customer
{
str += "\n" + o.GetInfo();  
}
}
return str;
}
}

class Order
{
private static int count = 0;
int order_id;
int customer;
DateTime order_time;
DateTime delivery_time;
string delivery_address;
double cost;
order_type otype;
bool Delivered { get; set; }
List<OrderItem> items;

public Order()
{
order_id = ++count; //increment count each time new Order obj is created
Delivered = false;
cost = 0;
items = new List<OrderItem>();
}

public Order(int custid, string deladdress, order_type type)
{
order_id = ++count; // increment count each time new Order obj is created
Delivered = false;
customer = custid;
order_time = System.DateTime.Now;
delivery_address = deladdress;
otype = type;
cost = 0;
items = new List<OrderItem>();
}

public void AddOrderItem(OrderItem m)
{
items.Add(m);
cost += m.getItemCost(); // add item cost to total order cost
}

public void Deliver()
{
delivery_time = System.DateTime.Now;
Delivered = true;
}
public string GetInfo()       // return order info as a string
{
string str;
str = "OrderNo:" + order_id + " , Ordered: " + order_time.ToString("MM/dd/yyyy hh:mm tt");
  
if (Delivered == false) // if its not deliverd
str += " NOT DELIVERD YET..";
else
str += " Delivered: " + delivery_time.ToString("MM/dd/yyyy hh:mm tt");
if (items.Count > 0)
{
str += "\n\tOrderItems:";
foreach (OrderItem i in items)
{
str += "\n\t" + i.GetInfo();
}
str += "\n--------------------\n";
str += "Deliver to: " + delivery_address + " Total $" + cost + ", OrderType: " + otype.ToString() + "\n\n";
}

return str;
}
}

class OrderItem
{
MenuItem Menu_item_name;

public OrderItem()
{
Menu_item_name = null;
}
public OrderItem(MenuItem m)
{
Menu_item_name = m;
}

public string GetInfo()
{
return Menu_item_name.GetInfo();
}

public double getItemCost()
{
return Menu_item_name.getMenuCost();
}

}

class MenuItem
{
string name;
string description;
double base_cost;

public MenuItem()
{
name = "";
description = "";
base_cost = 0;
}
public MenuItem(string n, string descr, double cost)
{
name = n;
description = descr;
base_cost = cost;
}
  
public string getName()
{
return name;
}

public double getMenuCost()
{
return base_cost;
}

public string GetInfo()
{
string str;
str = name + " " + description + " $" + base_cost; // return menu item info
return str;
}
}

class CustOrder // main driver class
{   

static void Main()
{
MenuItem tea = new MenuItem("Green Tea", "Healthy Grean Tea", 10);
MenuItem coffee = new MenuItem("Coffee", "Healthy Coffee", 20);
OrderItem t = new OrderItem(tea); // create orderItem from menuItem
OrderItem c = new OrderItem(coffee); // create orderItem from menuItem

Customer c1 = new Customer("John","Down Town", "01545687887");
Order tempOrder = new Order(c1.id_number,"my home", order_type.PhoneOrder); //create order
tempOrder.AddOrderItem(t); //add orderItem to order
tempOrder.AddOrderItem(c); //add orderItem to order

c1.CreateOrder(tempOrder); // assign that order to customer

Console.WriteLine(c1.GetInfo()); // display customer's and his order info

c1.orders[0].Deliver(); // deliver customer's order
Console.WriteLine(c1.GetInfo()); // again display customer's and his order info


Customer c2 = new Customer("Smith", "Top Hills", "656778998");
tempOrder = new Order(c2.id_number, "To Office", order_type.RestaurantOrder);
tempOrder.AddOrderItem(t);

c2.CreateOrder(tempOrder);
  
Console.WriteLine(c2.GetInfo());

//c2.orders[0].Deliver(); // remove comment to deliver order
//Console.WriteLine(c2.GetInfo()); // then print again
  

}
}
}

Add a comment
Know the answer?
Add Answer to:
The Code need to be in C# programming language. could you please leave some explanation notes...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast...

    In C++ Programming Write a program in Restaurant.cpp to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill. Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item): Name Price Egg (cooked to order)...

  • Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders...

    Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...

  • Create an Entity relationship diagram and write a databased design outline for the following: 1. You...

    Create an Entity relationship diagram and write a databased design outline for the following: 1. You want to keep track of sales team’s current sales activity. For each salesperson, you want to store unique employee ID, first name, last name, home address information, phone number, and email address. Your customers are typically retails stores and, for each customer, you want to store customer ID, name of business, phone number, address information and salesperson’s information. Also, for each customer, you want...

  • Hi the programming language for this assignment is C programming. Could you also please number the...

    Hi the programming language for this assignment is C programming. Could you also please number the answers exactly as they appear in the assignment? Thank you. (9) 1. An array of structures is needed to keep track of 50 grocery items containing the item name, item type, cost, quantity, and tax percentage for each grocery item. The following declarations have already been done: { struct grocery char name[20], type[15]: float cost, taxp: int quan: 3 Also, the following declaration has...

  • Entity relationship diagram (ERD) question: An online food delivery company hires you to design a small...

    Entity relationship diagram (ERD) question: An online food delivery company hires you to design a small database to store information about the online orders. You’re given the following requirements: ⚫ A customer is uniquely identified by his/her email. For each customer, we also record his/her name, phone number and address. The address is composed of suburb and street. ⚫ A rider is uniquely identified by his/her ID. We will keep record of the rider’s age, gender, phone number and available...

  • Create a program using C++ for a store. It will be a ledger for daily transactions....

    Create a program using C++ for a store. It will be a ledger for daily transactions. It should be able to record the transactions on a date. The transactions will happen at a given time (hour, minute, second). Also, every transaction must have a unique ID that is a number that is randomly generated by the system. *Note that the transaction has an ID, NOT the items. There will be no more than 10 transactions on a date. Within every...

  • Question: C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to prov......

    Question: C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to prov... C Programming Problem: Pointer and Struct Description: The purpose of this assignment is to provide practice programming using structs and pointers. Your program will accept user input and store it in a dynamic array of structs. First, you will define a structure to describe a item to be bought. Your program will prompt the user for the initial size of the array. It will...

  • C++ : Please include complete source code in answer This program will have names and addresses...

    C++ : Please include complete source code in answer This program will have names and addresses saved in a linked list. In addition, a birthday and anniversary date will be saved with each record. When the program is run, it will search for a birthday or an anniversary using the current date to compare with the saved date. It will then generate the appropriate card message. Because this will be an interactive system, your program should begin by displaying a...

  • The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in...

    The Case Express Delivery (ED) is a Morgantown based home goods company. Customers can call in orders and ED mails the items to the customer. They also email the customers a bill, as seen below. Customers can mail in a check, once they receive the order. ED needs to track whether the order has been paid or not, but the payment information is handled by a third-party vendor. ED needs to create a database to track their customers. Each customer...

  • Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses:...

    Programming Project 3 See Dropbox for due date Project Outcomes: Develop a Java program that uses: Exception handling File Processing(text) Regular Expressions Prep Readings: Absolute Java, chapters 1 - 9 and Regular Expression in Java Project Overview: Create a Java program that allows a user to pick a cell phone and cell phone package and shows the cost. Inthis program the design is left up to the programmer however good object oriented design is required.    Project Requirements Develop a text...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT