By GokiSoft.com|
13:57 28/10/2021|
C Sharp
Bài 2: Chương trình quản lý sản phẩm - Product - Lập Trình C# - Lập Trình C Sharp
Tạo class Product gồm các thuộc tính:
- Tên hàng hóa
- Nhà sản xuất
- Giá bán
+ Tạo 2 constructor cho lớp này.
+ Cài đặt hàm nhập và hiển thị.
Tạo class ProductMenu, khai báo hàm main và tạo menu sau:
1. Nhập thông tin cho n sản phẩm
2. Hiển thị thông tin vừa nhập
3. Sắp xếp thông tin giảm dần theo giá và hiển thị
4. Thoát.
Tags:
Phản hồi từ học viên
5
(Dựa trên đánh giá ngày hôm nay)
![Hoàng Quang Huy [C1907L]](https://www.gravatar.com/avatar/76e646e11f1674fba03bddd0ae020813.jpg?s=80&d=mm&r=g)
Hoàng Quang Huy
2020-07-01 13:34:12
using System;
namespace Project2
{
class Product
{
public string Name { get; set; }
public string Producer { get; set; }
public int Price { get; set; }
public Product(string name, string producer, int price)
{
Name = name;
Producer = producer;
Price = price;
}
public Product()
{
}
public void Input()
{
Console.WriteLine("Nhập tên hàng hóa: ");
this.Name = Console.ReadLine();
Console.WriteLine("Nhập tên nhà sản xuất: ");
this.Producer = Console.ReadLine();
Console.WriteLine("Nhập giá bán: ");
this.Price = int.Parse(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("Tên hàng hóa: "+ Name);
Console.WriteLine("Tên nhà sản xuất: "+Producer);
Console.WriteLine("Giá bán: "+Price);
}
}
}
-------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
namespace Project2
{
class ProductMenu
{
static List<Product> ListProduct { get; set; }
static void Main(string[] args)
{
Console.OutputEncoding = System.Text.Encoding.Unicode;
ListProduct = new List<Product>();
int choose;
do
{
ShowMenu();
choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
InputInfor();
break;
case 2:
ShowInfor();
break;
case 3:
SortByPrice();
break;
case 4:
Environment.Exit(0);
break;
default:
Console.WriteLine("Lựa chọn không hợp lệ!!");
break;
}
} while (choose != 4);
}
static void ShowMenu()
{
Console.WriteLine("1. Nhập thông tin cho n sản phẩm");
Console.WriteLine("2. Hiển thị thông tin vừa nhập");
Console.WriteLine("3. Sắp xếp thông tin giảm dần theo giá và hiển thị");
Console.WriteLine("4. Thoát");
Console.WriteLine("Lựa chọn của bạn: ");
}
static void InputInfor()
{
Console.WriteLine("Nhập số sản phẩm cần thêm: ");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Product product = new Product();
product.Input();
ListProduct.Add(product);
}
}
static void ShowInfor()
{
foreach (Product p in ListProduct )
{
p.Display();
}
}
static void SortByPrice()
{
for (int i = 0; i < ListProduct.Count-1; i++)
{
for (int j = i+1; j < ListProduct.Count; j++)
{
if (ListProduct[i].Price < ListProduct[j].Price)
{
Product tmp = ListProduct[i];
ListProduct[i] = ListProduct[j];
ListProduct[j] = tmp;
}
}
}
ShowInfor();
}
}
}
![Nguyễn Hoàng Anh [C1907L]](https://www.gravatar.com/avatar/5b7bb435cae0d0a0fd414f6fdd0adc87.jpg?s=80&d=mm&r=g)
Nguyễn Hoàng Anh
2020-07-01 13:30:20
using ProductManager;
using System;
using System.Collections.Generic;
namespace ProducManager
{
class Program
{
static void menu() {
Console.WriteLine("1.Enter N product.");
Console.WriteLine("2.Show product.");
Console.WriteLine("3.Sort.");
Console.WriteLine("4.Exit.");
}
static void input(List<Product> products) {
Console.WriteLine("How many product N.");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i< n;i++) {
Console.WriteLine("Enter product {0} : ",(i+1));
Product prod = new Product();
prod.input();
products.Add(prod);
}
}
static void display(List<Product> products) {
for (int i = 0; i < products.Count; i++) {
products[i].display();
}
}
static void sort(List<Product> products) {
for (int i = 0; i < products.Count; i++)
{
for (int j = i + 1; j < products.Count; j++) {
if (products[i].Price > products[j].Price) {
Product temp = products[i];
products[i] = products[j];
products[j] = temp;
}
}
}
}
static void Main(string[] args)
{
List<Product> products = new List<Product>();
while (true) {
menu();
int choice = int.Parse(Console.ReadLine());
switch(choice){
case 1:
input(products);
break;
case 2:
display(products);
break;
case 3:
sort( products);
break;
case 4:
return;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace ProductManager
{
class Product
{
public string NameProduct{get; set;}
public string Producer { get; set; }
public float Price { get; set; }
public Product(string nameProduct, string producer, float price)
{
NameProduct = nameProduct;
Producer = producer;
Price = price;
}
public Product()
{
}
public void input() {
Console.WriteLine("Enter product name : ");
NameProduct = Console.ReadLine();
Console.WriteLine("Enter producer : ");
Producer = Console.ReadLine();
Console.WriteLine("Enter price :");
Price = float.Parse(Console.ReadLine());
}
public void display() {
Console.WriteLine("Product name : {0} , Producer : {1} , Price : {2}",NameProduct,Producer,Price);
}
}
}
![trung [C1907L]](https://www.gravatar.com/avatar/67c23432e4710f33dd14e580d41b0379.jpg?s=80&d=mm&r=g)
trung
2020-07-01 13:29:33
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
{
class ProductMenu
{
static void Main(string[] args)
{
List<Product> ListProduct = new List<Product>();
int choice = 0;
do
{
showMenu();
choice = int.Parse(Console.ReadLine());
switch (choice)
{
case 1:
Console.WriteLine("Nhap vao so N");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.WriteLine("Nhap vao thong tin product thu" + (i + 1));
Product nProduct = new Product();
nProduct.Input();
ListProduct.Add(nProduct);
}
break;
case 2:
foreach (Product prd in ListProduct)
{
prd.Output();
}
break;
case 3:
for (int i = 0; i < ListProduct.Count - 1; i++)
{
for (int j = i + 1; j < ListProduct.Count; j++)
{
if (ListProduct[i].Price < ListProduct[j].Price)
{
Product temp = ListProduct[i];
ListProduct[i] = ListProduct[j];
ListProduct[j] = temp;
}
}
}
foreach (Product prd in ListProduct)
{
prd.Output();
}
break;
case 4:
Console.WriteLine("Bye bye...");
return;
default:
Console.WriteLine("Invalid input");
break;
}
} while (choice != 4);
}
static private void showMenu()
{
Console.WriteLine("Nhap thong tin cho n san pham");
Console.WriteLine("Hien thi thong tin vua nhap");
Console.WriteLine("Sap xep thong tin giam dan theo gia va hien thi");
Console.WriteLine("Thoat");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace product
{
class Product
{
public string Name { get; set; }
public string Producer { get; set; }
public float Price { get; set; }
public Product() { }
public Product(string name, string producer, float price)
{
Name = name;
Producer = producer;
Price = price;
}
public void Input()
{
Console.WriteLine("Input product name");
Name = Console.ReadLine();
Console.WriteLine("Input producer");
Producer = Console.ReadLine();
Console.WriteLine("Input price");
Price = int.Parse(Console.ReadLine());
}
public void Output()
{
Console.WriteLine("Product name: " + Name);
Console.WriteLine("Producer: " + Producer);
Console.WriteLine("Price: " + Price);
}
}
}
![Ngô Quang Huy [C1907L]](https://www.gravatar.com/avatar/8e54dbf5994077ce599f49278164ae79.jpg?s=80&d=mm&r=g)
Ngô Quang Huy
2020-07-01 13:20:12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program
{
class Program
{
static void Main(string[] args)
{
List<Product> listProduct = new List<Product>();
while (true)
{
showMenu();
int choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
Console.Write("N = ");
int n = int.Parse(Console.ReadLine());
for (int i= 0; i < n; i++)
{
Console.WriteLine("\nProduct "+(i+1));
Product prod = new Product();
prod.input();
listProduct.Add(prod);
}
break;
case 2:
foreach (Product pro in listProduct)
{
pro.output();
}
break;
case 3:
for (int i = 0; i < listProduct.Count-1; i++)
{
for (int j = i+1;j< listProduct.Count; j++)
{
if (listProduct[i].price < listProduct[j].price)
{
Product tmp = listProduct[i];
listProduct[i] = listProduct[j];
listProduct[j] = tmp;
}
}
}
foreach (Product pro in listProduct)
{
pro.output();
}
break;
default:
Environment.Exit(0);
break;
}
}
}
static void showMenu()
{
Console.WriteLine("1. Insert n product");
Console.WriteLine("2. Display product");
Console.WriteLine("3. Sort");
Console.WriteLine("4. Exit");
Console.Write("Choose: ");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Program
{
class Product
{
public string name { get; set; }
public string manufacturer { get; set; }
public float price{ get; set; }
public Product()
{
}
public Product(string name, string manufacturer, float price)
{
this.name = name;
this.manufacturer = manufacturer;
this.price = price;
}
public void input()
{
Console.WriteLine("Insert Name: ");
name = Console.ReadLine();
Console.WriteLine("Insert manufacturer: ");
manufacturer = Console.ReadLine();
Console.WriteLine("Insert price: ");
price = float.Parse(Console.ReadLine());
}
public void output()
{
Console.WriteLine("name: " + name + "; "+"manufacturer: " + manufacturer + "; "+"price: " + price);
}
}
}
![Trần Anh Quân [T1907A]](https://www.gravatar.com/avatar/7e3a8fe30cedd711f426fc59a9d48efc.jpg?s=80&d=mm&r=g)
Trần Anh Quân
2020-06-01 15:15:12
using System;
using System.Collections.Generic;
namespace qlsp
{
class Program
{
static void Main(string[] args)
{
List<Product> productList = new List<Product>();
int choose;
do
{
ShowMenu();
choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
Console.WriteLine("N san pham muon them ");
int n = int.Parse(Console.ReadLine());
Product pro = new Product();
for (int i=0; i <n; i++)
{
pro = new Product();
pro.Input();
productList.Add(pro);
}
break;
case 2:
foreach(Product propro in productList)
{
propro.Display();
}
break;
case 3 :
productList.Sort((a, b) => a.Price.CompareTo(b.Price));
foreach (Product propro in productList)
{
propro.Display();
}
break;
case 4:
Console.WriteLine("Thoat");
break;
default:
Console.WriteLine("Nhap khong chinh xac ( chi nhap tu 1-4)");
break;
}
} while (choose != 5);
}
static void ShowMenu()
{
Console.WriteLine("1. So san pham muon them : ");
Console.WriteLine("2. Thong tin vua nhap : ");
Console.WriteLine("3. Sap xep thong tin giam dan theo gia va hien thi : ");
Console.WriteLine("4. Thoat : ");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace qlsp
{
class Product
{
public string NameProduct { get; set; }
public string Producer { get; set; }
public float Price { get; set; }
public Product()
{
}
public Product(string NameProduct,string Producer,float Price)
{
this.Producer = Producer;
this.NameProduct = NameProduct;
this.Price = Price;
}
public void Input()
{
Console.WriteLine("Nhap ten san pham :");
NameProduct = Console.ReadLine();
Console.WriteLine("Nhap nha san xuat :");
Producer = Console.ReadLine();
Console.WriteLine("Nhap gia tien :");
Price = float.Parse(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("Ten san pham : {0},Nha san xuat : {1}, Gia ban : {2}",NameProduct,Producer,Price);
}
}
}
![Phan Bạch Tùng Dương [T1907A]](https://www.gravatar.com/avatar/e74e3ec62fe3a191929e12eecbe01edf.jpg?s=80&d=mm&r=g)
Phan Bạch Tùng Dương
2020-05-29 02:14:21
using System;
using System.Collections.Generic;
using System.Text;
namespace Lession6
{
class Program
{
public static int chosse;
public static void Main(String[] agrs)
{
Console.InputEncoding = Encoding.UTF8;
Console.OutputEncoding = Encoding.UTF8;
List<Product> Products = new List<Product>();
do
{
showMenu();
checkChosse();
switch (chosse)
{
case 1:
input(Products);
break;
case 2:
display(Products);
break;
case 3:
sort(Products);
display(Products);
break;
case 4:
Console.WriteLine("Stop!!!!!");
break;
default:
Console.WriteLine("Error!!! Please try again.....");
break;
}
} while (chosse != 4);
}
public static void showMenu()
{
Console.WriteLine("\t\t\tMenu");
Console.WriteLine("1. Nhap thong tin cho n san pham ");
Console.WriteLine("2. Hien thi thong tin vua nhap: ");
Console.WriteLine("3. Sap xep thong tin giam dan theo gia va hien thi: ");
Console.WriteLine("4. Exit. ");
}
static void input(List<Product> Products)
{
for (; ; )
{
Product product = new Product();
product.input();
Products.Add(product);
Console.WriteLine("nhap them product : (Y/N)");
string option = Console.ReadLine();
if (option.ToUpper().Equals("N"))
{
break;
}
}
}
static void display(List<Product> Products)
{
foreach (var item in Products)
{
item.display();
}
}
static void sort(List<Product> Products)
{
Products.Sort((x, y) => y.Price.CompareTo(x.Price));
}
private static void checkChosse()
{
bool isName = true;
while (isName)
{
string str;
Console.Write("Chon: ");
str = Console.ReadLine();
if (String.IsNullOrEmpty(str))
{
Console.WriteLine("Lua chon khong duoc de trong!!!");
}
else
{
if (check(str))
{
chosse = int.Parse(str);
if (chosse > 0)
{
isName = false;
}
else
{
Console.WriteLine("Lua chon phai lon hon 0");
}
}
else
{
Console.WriteLine("Khong duoc nhap chu!! ");
}
}
}
}
static bool check(string s)
{
bool checkk = false;
foreach (char item in s)
{
if (item >= 48 && item <= 57)
{
checkk = true;
}
}
return checkk;
}
}
}
using System;
namespace Lession6
{
class Product
{
public string Name { get; set; }
public string Producer { get; set; }
private float _price;
public float Price
{
get
{
return _price;
}
set
{
if (value >= 0)
{
this._price = value;
}
else
{
Console.WriteLine("Gia nhap vao phai lon hon 0");
}
}
}
public Product() { }
public Product(string Name, string Producer, float Price)
{
this.Name = Name;
this.Producer = Producer;
this.Price = Price;
}
public void input()
{
checkName();
checkProducer();
checkPrice();
}
public void display()
{
Console.WriteLine("Ten: {0}\nNha san xuat: {1}\nGia: {2}", Name, Producer, Price);
}
private void checkName()
{
bool isName = true;
while (isName)
{
Console.Write("Nhap ten san pham: ");
Name = Console.ReadLine();
if (String.IsNullOrEmpty(Name))
{
Console.WriteLine("Ten san pham khong duoc de trong!!!");
}
else
{
isName = false;
}
}
}
private void checkProducer()
{
bool isName = true;
while (isName)
{
Console.Write("Nhap ten nha san xuat: ");
Producer = Console.ReadLine();
if (String.IsNullOrEmpty(Producer))
{
Console.WriteLine("Ten nha san khong duoc de trong!!!");
}
else
{
isName = false;
}
}
}
private void checkPrice()
{
bool isName = true;
while (isName)
{
Console.Write("Nhap gia san pham: ");
string str;
str = Console.ReadLine();
if (String.IsNullOrEmpty(str))
{
Console.WriteLine("Gia san pham khong duoc de trong!!!");
}
else
{
Price = float.Parse(str);
if (Price > 0)
{
isName = false;
}
}
}
}
}
}
![Phạm Ngọc Minh [T1907A]](https://www.gravatar.com/avatar/9fa44938f36838ed4b4ac8e30e070c74.jpg?s=80&d=mm&r=g)
Phạm Ngọc Minh
2020-05-28 15:32:09
using System;
using System.Collections.Generic;
namespace QLSP
{
class Program
{
static void Main(string[] args)
{
List<Product> productList = new List<Product>();
int choose;
do
{
ShowMenu();
choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
Console.WriteLine("N san pham muon them ");
int n = int.Parse(Console.ReadLine());
Product pro = new Product();
for (int i=0; i <n; i++)
{
pro = new Product();
pro.Input();
productList.Add(pro);
}
break;
case 2:
foreach(Product propro in productList)
{
propro.Display();
}
break;
case 3 :
productList.Sort((a, b) => a.Price.CompareTo(b.Price));
foreach (Product propro in productList)
{
propro.Display();
}
break;
case 4:
Console.WriteLine("Thoat");
break;
default:
Console.WriteLine("Nhap khong chinh xac ( chi nhap tu 1-4)");
break;
}
} while (choose != 5);
}
static void ShowMenu()
{
Console.WriteLine("1. So san pham muon them : ");
Console.WriteLine("2. Thong tin vua nhap : ");
Console.WriteLine("3. Sap xep thong tin giam dan theo gia va hien thi : ");
Console.WriteLine("4. Thoat : ");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace QLSP
{
class Product
{
public string NameProduct { get; set; }
public string Producer { get; set; }
public float Price { get; set; }
public Product()
{
}
public Product(string NameProduct,string Producer,float Price)
{
this.Producer = Producer;
this.NameProduct = NameProduct;
this.Price = Price;
}
public void Input()
{
Console.WriteLine("Nhap ten san pham :");
NameProduct = Console.ReadLine();
Console.WriteLine("Nhap nha san xuat :");
Producer = Console.ReadLine();
Console.WriteLine("Nhap gia tien :");
Price = float.Parse(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("Ten san pham : {0},Nha san xuat : {1}, Gia ban : {2}",NameProduct,Producer,Price);
}
}
}
![nguyễn văn huy [T1907A]](https://www.gravatar.com/avatar/b107d14d7d43c142b68c12c377262371.jpg?s=80&d=mm&r=g)
nguyễn văn huy
2020-05-27 03:22:47
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
namespace sanpham
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
List<Sanpham> thaolist = new List<Sanpham>();
Sanpham sanpham = new Sanpham();
int choise;
do
{
menu();
choise = Int32.Parse(Console.ReadLine());
switch (choise)
{
case 1:
Console.WriteLine("nhập nsanr phẩm:");
int n = Int32.Parse(Console.ReadLine());
for(int i = 0; i < n; i++)
{
Sanpham sanpham1 = new Sanpham();
sanpham1.input();
thaolist.Add(sanpham1);
}
break;
case 2:
foreach (Sanpham sanpham in thaolist)
{
sanpham.display();
}
break;
case 3:
sort(thaolist);
sanpham.display();
break;
case 4:
Console.WriteLine("thoát!!!");
break;
default:
Console.WriteLine(">>>>>>");
break;
}
} while (choise != 4);
}
static void menu()
{
Console.WriteLine("1.Nhập thông tin n sản phẩm");
Console.WriteLine("2.Hiển thị thông tin sản phẩm");
Console.WriteLine("3.Sắp xếp thông tin giảm dần thao giá:");
Console.WriteLine("4.Choise");
}
static void sort(List<Sanpham> thaolist)
{
thaolist.Sort((x, y) => x.Giaban.CompareTo(y.Giaban));
}
}
}
>>>>>>
using System;
using System.Collections.Generic;
using System.Dynamic;
using System.Text;
namespace sanpham
{
class Sanpham
{
private String Name { get; set; }
private String Nhasx { get; set; }
private int Giaban { get; set; }
public void input()
{
Console.WriteLine("nhập tên sp:");
Name = Console.ReadLine();
Console.WriteLine("nhập nhà sản xuất:");
Nhasx = Console.ReadLine();
Console.WriteLine("nhập giá bán:");
Giaban = int.Parse(Console.ReadLine());
}
public void display()
{
Console.WriteLine("{0},{1},{2},", Name, Nhasx, Giaban);
}
}
}
![Phí Văn Long [T1907A]](https://www.gravatar.com/avatar/5db166b7b74443c5c221e4c0068d6da9.jpg?s=80&d=mm&r=g)
Phí Văn Long
2020-05-26 09:47:07
using System;
using System.Collections.Generic;
namespace QLSanPham
{
class Program
{
static void Main(string[] args)
{
List<Product> productList = new List<Product>();
int choose;
do
{
ShowMenu();
choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
Console.WriteLine("N san pham muon them ");
int n = int.Parse(Console.ReadLine());
Product pro = new Product();
for (int i=0; i <n; i++)
{
pro = new Product();
pro.Input();
productList.Add(pro);
}
break;
case 2:
foreach(Product propro in productList)
{
propro.Display();
}
break;
case 3 :
productList.Sort((a, b) => a.Price.CompareTo(b.Price));
foreach (Product propro in productList)
{
propro.Display();
}
break;
case 4:
Console.WriteLine("Thoat");
break;
default:
Console.WriteLine("Nhap khong chinh xac ( chi nhap tu 1-4)");
break;
}
} while (choose != 5);
}
static void ShowMenu()
{
Console.WriteLine("1. So san pham muon them : ");
Console.WriteLine("2. Thong tin vua nhap : ");
Console.WriteLine("3. Sap xep thong tin giam dan theo gia va hien thi : ");
Console.WriteLine("4. Thoat : ");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace QLSanPham
{
class Product
{
public string NameProduct { get; set; }
public string Producer { get; set; }
public float Price { get; set; }
public Product()
{
}
public Product(string NameProduct,string Producer,float Price)
{
this.Producer = Producer;
this.NameProduct = NameProduct;
this.Price = Price;
}
public void Input()
{
Console.WriteLine("Nhap ten san pham :");
NameProduct = Console.ReadLine();
Console.WriteLine("Nhap nha san xuat :");
Producer = Console.ReadLine();
Console.WriteLine("Nhap gia tien :");
Price = float.Parse(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("Ten san pham : {0},Nha san xuat : {1}, Gia ban : {2}",NameProduct,Producer,Price);
}
}
}
![hoangduyminh [T1907A]](https://www.gravatar.com/avatar/33675cc9fc3762fd323389a179aa047f.jpg?s=80&d=mm&r=g)
hoangduyminh
2020-05-26 08:44:15
using System;
using System.Collections.Generic;
namespace QuanLiSP
{
class Program
{
static void Main(string[] args)
{
int choose;
List<Product> products = new List<Product>();
do
{
showMenu();
choose = int.Parse(Console.ReadLine());
switch (choose)
{
case 1:
Console.WriteLine("Nhap vao n san pham:");
int n = int.Parse(Console.ReadLine());
Product product = new Product();
for(int i = 0; i < n; i++)
{
product = new Product();
product.input();
products.Add(product);
}
break;
case 2:
foreach(Product product1 in products)
{
product1.display();
}
break;
case 3:
products.Sort((x, y) => y.Price.CompareTo(x.Price));
foreach(Product product1 in products)
{
product1.display();
}
break;
case 4:
Console.WriteLine("Thoat!!");
break;
default:
Console.WriteLine("Error!");
break;
}
} while (choose != 5);
}
static void showMenu()
{
Console.WriteLine("1.Nhap thong tin n cho san pham");
Console.WriteLine("2.Hien thi thong tin vua nhap");
Console.WriteLine("3.Sap xep thong tin giam dan theo gia va hien thi");
Console.WriteLine("4.Thoat!");
Console.WriteLine("Choose");
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace QuanLiSP
{
class Product
{
public string NameHH { get; set; }
public string NSX { get; set; }
public int Price { get; set; }
public Product()
{
}
public void input()
{
Console.WriteLine("Nhap vao NameHH:");
NameHH = Console.ReadLine();
Console.WriteLine("Nhap vao NSX:");
NSX = Console.ReadLine();
Console.WriteLine("Nhap vao Gia:");
Price = int.Parse(Console.ReadLine());
}
public void display()
{
Console.WriteLine("Product: NameHH{0}, NSX{1}, Gia{2}", NameHH, NSX, Price);
}
}
}