bai nay minh code lai nhung con cho sai mong ban sua dum minh
- Code:
class date
{
public date(byte ngay, byte thang, short nam)
{
this.ngay = ngay;
this.thang = thang;
this.nam = nam;
}
public void getngay(out byte ngay, out byte thang, out short nam)
{
ngay = this.ngay;
thang = this.thang;
nam = this.nam;
}
byte ngay;
byte thang;
short nam;
}
- Code:
class time
{
public time(byte gio, byte phut)
{
this.gio = gio;
this.phut = phut;
}
public void getgio(out byte gio, out byte phut)
{
gio = this.gio;
phut = this.phut;
}
byte gio;
byte phut;
}
- Code:
class ticket
{
public ticket(date ngaykhoihanh, time giokhoihanh, string hovatenkh, byte soluongve, double giave, byte loaicabin, bool khuyenmai)
{
this.ngaykhoihanh = ngaykhoihanh;
this.giokhoihanh = giokhoihanh;
this.hovatenkh = hovatenkh;
this.soluongve = soluongve;
this.giave = giave;
this.loaicabin = loaicabin;
this.khuyenmai = khuyenmai;
}
public date ngaykhoihanh
{
get
{
return ngaykhoihanh;
}
set
{
ngaykhoihanh = value;
}
}
public time giokhoihanh
{
get
{
return giokhoihanh;
}
set
{
giokhoihanh = value;
}
}
public double tienkhuyenmai()
{
byte ngay , thang , nam ,gio , phut ;
short nam ;
double tkm =0;
if ( khuyenmai )
{
if ( loaicabin ==1 && soluongve >3 )
tkm == 0.2 * soluongve * giave ;
if ( loaicabin == 2 && soluongve >2 )
tkm == 0.25 * soluongve * giave * loaicabin ;
if ( loaicabin ==3 && soluongve >1 )
tkm == 0.3 * soluongve * giave * loaicabin ;
}
getngay( out ngay , out thang , out nam );
getgio ( out gio , out phut );
if ( gio <6 || gio == 6 && phut <31 )
tkm += 0.15 * soluongve * giave * loaicabin ;
else if (ngay < 6 )
tkm += 0.1 * soluongve * giave * loaicabin ;
return tkm;
}
public double tongtien()
{
return soluongve * giave * loaicabin - tienkhuyenmai();
}
public void hienthingay()
{
byte ngay, thang;
short nam ;
ngaykhoihanh.getngay(out ngay, out thang, out nam);
Console.WriteLine("{0},{1},{2}", ngay, thang, nam);
}
public void hienthigio ()
{
byte gio , phut ;
giokhoihanh.getgio ( out gio , out phut );
Console.WriteLine("{0},{1}", gio , phut );
}
public void hienthithongtin()
{
Console.WriteLine(" ho va ten khach hang : {0}", hovatenkh);
Console.WriteLine(" soluongve :{0}", soluongve);
Console.WriteLine(" loaicabin : {0}", loaicabin);
Console.WriteLine(" hienthingay :"); hienthingay();
Console.WriteLine(" hine thi gio :"); hienthigio();
}
date ngaykhoihanh;
time giokhoihanh;
string hovatenkh;
byte soluongve;
double giave;
byte loaicabin;
bool khuyenmai;
}
}
- Code:
class tests
{
date date = new date(20, 11, 1990);
time time = new time(5, 30);
ticket ve = new ticket(date, time, " nguyen minh ", 1, 100000, 2, true);
Console.WriteLine ( " thong tin ve :") ve.hienthithongtin();
Console.ReadLine();
}