



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
this is useful in object oriented programming in c#
Typology: Cheat Sheet
1 / 5
This page cannot be seen from the preview
Don't miss anything!




using System; using System.Collections.Generic; classProduct { public string Name { get; set; } public string Category { get; set; } public int Price { get; set; }
public Product(string name, string category, int price) { Name = name;
Category = category; Price = price; }
public float CalculateTax() { return Price * 0.10f;
public void AddProduct(Product product) { products.Add(product); }
classCustomer { public string CustomerName { get; set; } public string CustomerAddress { get; set; } public string CustomerContact { get; set; }
private List products = new List();
public Customer(string name, string address, string contact) { CustomerName = name; CustomerAddress = address; CustomerContact = contact; }
Console.ReadLine(); } }
customer.DisplayDetails();
customer.AddProduct(p1); customer.AddProduct(p2);
Console.WriteLine("\nTOTAL BILL"); Console.WriteLine("====================="); Console.WriteLine("Total Price: Rs. " + total); Console.WriteLine("Total Tax: Rs. " + totalTax); Console.WriteLine("Grand Total: Rs. " + (total + totalTax)); }
Product p1 = new Product("Tablet", "Electronics", 40000); Product p2 = new Product("Bluetooth Speaker", "Accessories", 7000);
classProgram { static void Main() { Customer customer = new Customer("Hamza Khan", "Multan", "0321-5556677");