using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Bài_1
{
class Program
{
class Tailieu
{
private int Matl, Sobph;
private string Tennxb;
public Tailieu()
{
}
public Tailieu(int ma, string ten, int so)
{
Matl = ma;
Tennxb = ten;
Sobph = so;
}
public int MaTaiLieu
{
get { return Matl; }
set { Matl = value; }
}
public string TenNhaXuatBan
{
get { return Tennxb; }
set { Tennxb = value; }
}
public int SoPhatHanh
{
get { return Sobph; }
set { Sobph = value; }
}
}
class Sach : Tailieu
{
private string Tentg;
private int Sotrang;
public Sach(int matailieu, string tennhaxuatban, int sobanphathanh, string tentacgia, int sotrang) : base(matailieu, tennhaxuatban, sobanphathanh)
{
this.Tentg = tentacgia;
this.Sotrang = sotrang;
}
}
class Tapchi : Tailieu
{
private int Soph, Thangph;
public Tapchi(int matailieu, string tennhaxuatban, int sobanphathanh, int sophathanh, int thangphathanh) : base(matailieu, tennhaxuatban, sobanphathanh)
{
this.Soph = sophathanh;
this.Thangph = thangphathanh;
}
}
class Bao : Tailieu
{
private int Ngayph;
public Bao(int matailieu, string tennhaxuatban, int sobanphathanh, int ngayphathanh) : base(matailieu, tennhaxuatban, sobanphathanh)
{
this.Ngayph = ngayphathanh;
}
}
static void Main(string[] args)
{
Tailieu tailieu1 = new Tailieu(01, "Dai Nam", 10);
Tailieu tailieu2 = new Tailieu(02, "Dai Nam", 11);
Tailieu tailieu3 = new Tailieu(03, "Dai Nam", 12);
Tailieu tailieu4 = new Tailieu(04, "Dai Nam", 13);
List<Tailieu> Danhsachtailieu = new List<Tailieu> { tailieu1, tailieu2, tailieu3, tailieu4 };
Console.WriteLine("----------Menu----------");
Console.Write("0: Nhap thong tin tai lieu\n1: Tim kiem tai lieu\n2: In danh sach thong tin tai lieu\n3: Thoat\nHay nhap lua chon cua ban: ");
int so = int.Parse(Console.ReadLine());
switch (so)
{
case 0:
// Nhap thong tin can bo
Console.Write("Ban hay nhap so luong muon them thong tin: ");
int a = int.Parse(Console.ReadLine());
for (int i = 0; i < a; i++)
{
Console.WriteLine("Nhap thong tin tai lieu:");
Console.WriteLine("{0}:", i + 1);
Console.Write("Nhap ma tai lieu: ");
int nhapma = int.Parse(Console.ReadLine());
Console.Write("Nhap ten nha xuat ban: ");
string nhaptennhaxuatban = Console.ReadLine();
Console.Write("Nhap so phat hanh: ");
int nhapsobanphathanh = int.Parse(Console.ReadLine());
// Them can bo vao list
var p = new Tailieu(nhapma, nhaptennhaxuatban, nhapsobanphathanh);
Danhsachtailieu.Add(p);
Console.Write("\n");
}
Console.Write("\n");
Console.Write("0: Nhap thong tin tai lieu\n1: Tim kiem tai lieu\n2: In danh sach thong tin tai lieu\n3: Thoat\nHay nhap lua chon cua ban: ");
int b = int.Parse(Console.ReadLine());
if (b == 0) goto case 0;
if (b == 1) goto case 1;
if (b == 2) goto case 2;
if (b == 3) goto case 3;
break;
case 1:
Console.Write("Nhap ten nha xuat ban: ");
string c = Console.ReadLine();
foreach (Tailieu item in Danhsachtailieu)
{
if (item.TenNhaXuatBan == c)
{
Console.WriteLine(item.MaTaiLieu + "\t" + item.TenNhaXuatBan + "\t" + item.SoPhatHanh + "\n");
}
}
Console.Write("0: Nhap thong tin tai lieu\n1: Tim kiem tai lieu\n2: In danh sach thong tin tai lieu\n3: Thoat\nHay nhap lua chon cua ban: ");
int d = int.Parse(Console.ReadLine());
if (d == 0) goto case 0;
if (d == 1) goto case 1;
if (d == 2) goto case 2;
if (d == 3) goto case 3;
break;
case 2:
Console.WriteLine("Danh sach thong tin tai lieu:");
foreach (Tailieu item in Danhsachtailieu)
{
Console.WriteLine(item.MaTaiLieu + "\t" + item.TenNhaXuatBan + "\t" + item.SoPhatHanh + "\n");
}
Console.Write("0: Nhap thong tin tai lieu\n1: Tim kiem tai lieu\n2: In danh sach thong tin tai lieu\n3: Thoat\nHay nhap lua chon cua ban: ");
int e = int.Parse(Console.ReadLine());
if (e == 0) goto case 0;
if (e == 1) goto case 1;
if (e == 2) goto case 2;
if (e == 3) goto case 3;
break;
case 3:
break;
default:
break;
}
}
}
}