You are on page 1of 3

Trng i hc S Phm TP.

HCM Khoa Cng Ngh Thng Tin

THI THC HNH KT THC HC PHN Mn thi: LP TRNH HNG I TNG Hc k 2/2013 Thi gian: 60 pht khng k thi gian pht (Dnh cho lp SPTin2, CNTT2)

B7
( thi gm c 2 trang)
Khng c php s dng ti liu, Internet Khng c php trao i bi vi ngi khc di bt k hnh thc no Khng s dng a mm, CD, HDD, USB Disk hay bt k thit b no c kh nng truyn v nhn tn hiu

Mt cng ty vin thng cn qun l cc thu bao khch hng. Mi thu bao c cc thng tin: s thu bao (s in thoi), CMND ca ngi s dng, h v tn ca ngi s dng. C 2 loi thu bao l: thu bao Blue v thu bao Green. Thu bao Blue mi ln np tin thm s c tng 100%. Cc cuc gi l 30/giy trong 3 pht u v t 3 pht 1 giy tr ln th tnh theo cc 25/giy. Thu bao Green mi ln np tin thm s c tng 5 pht min ph cho mi 10.000VN (nu np 25000 th ch tng 5x2 pht gi min ph). Khi gi th s pht khuyn mi s c tr trc. Khi khng cn s pht khuyn mi th bt u tnh cc. Cc cuc gi l 25/giy. Yu cu: Xy dng lp Lease qun l chung 2 loi trn gm c cc thnh phn sau: - Property readonly LeaseID (kiu string): cho bit s thu bao - Property readonly FullName (kiu string): cho bit h tn ca ch thu bao - Property readonly Balance (kiu int): cho bit tng tin c trong ti khon ca thu bao - Phng thc tru tng void Credit(int amountofmoney): dng np thm tin cho thu bao vi tham s truyn vo l s tin (VN) m khch hng np vo. - Phng thc tru tng bool Call(int numberofseconds): dng thc thi khi khch hng gi in thoi. Vi tham s truyn vo l tng s giy trong cuc gi . C th sau cuc gi s tin ca thu bao l gi tr m. Nhng trc khi gi nu s tin trong thu bao l gi tr khng dng th tr v false v khng thc hin cuc gi . Ngc li th tr v true. - K tha hm string ToString() ca lp Object. Tr v chui string c dng nh sau: {LeaseID}:{FullName}:{Balance}. V d LeaseID = 0901234567, FullName = Nguyen Van A, Balance = 0 th s tr v chui string nh sau: {0901234567}:{Nguyen Van A}:{0}. Xy dng lp LeaseBlue. Lp LeaseBlue ging vi Lease. LeaseBlue c thm cc thnh phn sau: - Hm khi to LeaseBlue (string id, string name, int n): id, name v n ln lt l s thu bao v h tn khch hng v s tin ca thu bao. - Hm khi to LeaseBlue (string id, string name): id v name ln lt l s thu bao v h tn khch hng, s tin ca thu bao mc nh bng 0. - Hin thc li phng thc void Credit(int amountofmoney) - Hin thc li phng thc bool Call(int numberofseconds) Xy dng lp LeaseGreen. Lp LeaseGreen ging vi Lease. LeaseGreen c thm cc thnh phn sau: - Property readonly NumberMinuteFree(kiu int): cho bit tng s giy min ph - Hm khi to LeaseGreen (string id, string name, int n, int f): id, name, n v f ln lt l s thu bao v h tn khch hng, s tin ca thu bao v s pht min ph cn li. Trang 1/2

Hm khi to LeaseGreen (string id, string name): id v name ln lt l s thu bao v h tn khch hng, s tin ca thu bao mc nh bng 0, s pht min ph cn li bng 0. Hin thc li phng thc void Credit(int amountofmoney) Hin thc li phng thc bool Call(int numberofseconds)

Lu : - Sinh vin t vit hm main test cc lp trn. Hm main ch dng bn t test trn my. Gim kho khng chm im da trn hm main ca bn. - Tn project c t theo m s sinh vin. V d: sinh vin c m s K36.104.999 s t tn project l K36104999 - Khng gii quyt cho trng hp mt bi do qun lu file, lu sai th mc, nh dng, qun ghi h tn, MSSV hay t sai tn project. - Khng gii quyt cho trng hp t sai tn hm, tn lp v sai danh sch tham s. - Sinh vin c thm 5 pht c k bi sau khi pht . Cn b coi thi khng gii thch g thm - Bi lm vn cn li syntax coi nh c 0 im Thang im nh gi: KTQ (iu kin tin quyt ngha l nu khng qua c s khng chm tip cc tiu ch tip theo) Tiu ch 2 - 5 p dng cho lp Lease v lp LeaseBlue. Tiu ch 6 - 9 p dng cho lp LeaseGreen Tiu ch 1 Khai bo tn lp Lease, LeaseBlue, LeaseGreen (KTQ) Lp LeaseBlue v LeaseGreen k tha t Lease Tiu ch 2 Khai bo ng 2 hm khi to Khai bo ng 3 property Khai bo ng 3 method Tiu ch 3 Hin thc ng hm khi to 3 tham s (KTQ) Hin thc ng 3 property Tiu ch 4 Hin thc ng hm khi to 2 tham s Tiu ch 5 Hin thc ng hm Credit Hin thc ng hm Call Hin thc ng hm ToString ( lp cha) Tiu ch 6 Khai bo ng property NumberMinuteFree Khai bo ng 2 hm khi to Khai bo ng 2 method Tiu ch 7 Hin thc ng hm khi to 4 tham s (KTQ) Hin thc ng property NumberMinuteFree Tiu ch 8 Hin thc ng hm khi to 2 tham s Tiu ch 9 Hin thc ng hm Credit Trang 2/2 3 2 2 3 3 0 15 3 4 16 4 1 2 2 0 5 4 5

Hin thc ng hm Call Tng cng

20 94

Trang 3/2