SHOW:
|
|
- or go back to the newest paste.
1 | - | package Programming.edu.oo; |
1 | + | package game; |
2 | ||
3 | - | public class Trunggian { |
3 | + | public abstract class Game { |
4 | - | private String Hoten, Namsinh, Mathe; |
4 | + | private String Name, Phonenumber, Address; |
5 | - | public Trunggian(){ |
5 | + | private double Songuoichoi, Sovanchoi, Sovanthua, Sovanthang, Tienvon; |
6 | public static final double Tienga = 2000; | |
7 | - | public Trunggian(String Hoten,String Namsinh,String Mathe ){ |
7 | + | public static final double Thua = 10000; |
8 | - | this.Hoten = Hoten; |
8 | + | public static final double Thang = 10000; |
9 | - | this.Namsinh = Namsinh; |
9 | + | public Game(){ |
10 | - | this.Mathe = Mathe; |
10 | + | |
11 | } | |
12 | - | public String getHoten() { |
12 | + | public Game( String name, String phonenumber, String address, double songuoichoi, double sovanchoi, double sovanthua, double sovanthang, double tienvon){ |
13 | - | return Hoten; |
13 | + | this.Name = name; |
14 | this.Phonenumber = phonenumber; | |
15 | - | public void setHoten(String hoten) { |
15 | + | this.Address = address; |
16 | - | Hoten = hoten; |
16 | + | this.Songuoichoi = songuoichoi; |
17 | this.Sovanchoi = sovanchoi; | |
18 | - | public String getNamsinh() { |
18 | + | this.Sovanthang = sovanthang; |
19 | - | return Namsinh; |
19 | + | this.Sovanthua = sovanthua; |
20 | this.Tienvon = tienvon; | |
21 | - | public void setNamsinh(String namsinh) { |
21 | + | |
22 | - | Namsinh = namsinh; |
22 | + | |
23 | public String getName() { | |
24 | - | public String getMathe() { |
24 | + | return Name; |
25 | - | return Mathe; |
25 | + | |
26 | public void setName(String name) { | |
27 | - | public void setMathe(String mathe) { |
27 | + | Name = name; |
28 | - | Mathe = mathe; |
28 | + | |
29 | public String getPhonenumber() { | |
30 | return Phonenumber; | |
31 | } | |
32 | public void setPhonenumber(String phonenumber) { | |
33 | - | package Programming.edu.oo; |
33 | + | Phonenumber = phonenumber; |
34 | } | |
35 | - | public class Hocsinh extends Trunggian { |
35 | + | public String getAddress() { |
36 | - | private String HPno; |
36 | + | return Address; |
37 | - | public Hocsinh(){ |
37 | + | |
38 | public void setAddress(String address) { | |
39 | - | public Hocsinh (String Hoten, String Namsinh, String Mathe, String HPno){ |
39 | + | Address = address; |
40 | - | super(Hoten, Namsinh, Mathe); |
40 | + | |
41 | - | this.HPno = HPno; |
41 | + | public double getSonguoichoi() { |
42 | return Songuoichoi; | |
43 | - | public String getHPno() { |
43 | + | |
44 | - | return HPno; |
44 | + | public void setSonguoichoi(double songuoichoi) { |
45 | Songuoichoi = songuoichoi; | |
46 | - | public void setHPno(String hPno) { |
46 | + | |
47 | - | HPno = hPno; |
47 | + | public double getSovanchoi() { |
48 | return Sovanchoi; | |
49 | } | |
50 | public void setSovanchoi(double sovanchoi) { | |
51 | - | package Programming.edu.oo; |
51 | + | Sovanchoi = sovanchoi; |
52 | } | |
53 | - | public class Giaovien extends Trunggian { |
53 | + | public double getSovanthua() { |
54 | - | private String Tienluong; |
54 | + | return Sovanthua; |
55 | - | public Giaovien(){ |
55 | + | |
56 | public void setSovanthua(double sovanthua) { | |
57 | - | public Giaovien(String Hoten, String Namsinh, String Mathe, String Tienluong){ |
57 | + | Sovanthua = sovanthua; |
58 | - | super(Hoten, Namsinh, Mathe); |
58 | + | |
59 | - | this.Tienluong = Tienluong; |
59 | + | public double getSovanthang() { |
60 | return Sovanthang; | |
61 | - | public String getTienluong() { |
61 | + | |
62 | - | return Tienluong; |
62 | + | public void setSovanthang(double sovanthang) { |
63 | Sovanthang = sovanthang; | |
64 | - | public void setTienluong(String tienluong) { |
64 | + | |
65 | - | Tienluong = tienluong; |
65 | + | public double getTienvon() { |
66 | return Tienvon; | |
67 | } | |
68 | public void setTienvon(double tienvon) { | |
69 | - | package Programming.edu.oo; |
69 | + | Tienvon = tienvon; |
70 | } | |
71 | - | public class Giamdoc extends Trunggian { |
71 | + | abstract double Tongtien(); |
72 | - | private String Tientieu; |
72 | + | |
73 | } | |
74 | - | public Giamdoc() { |
74 | + | |
75 | ||
76 | package game; | |
77 | - | public Giamdoc(String Hoten, String Namsinh, String Mathe, String Tientieu) { |
77 | + | |
78 | - | super(Hoten, Namsinh, Mathe); |
78 | + | public class Bacay extends Game { |
79 | - | this.Tientieu = Tientieu; |
79 | + | private double Muoi; |
80 | ||
81 | public Bacay() { | |
82 | - | public String getTientieu() { |
82 | + | |
83 | - | return Tientieu; |
83 | + | |
84 | public Bacay(double muoi, String name, String phonenumber, | |
85 | String address, double songuoichoi, double sovanchoi, | |
86 | - | public void setTientieu(String tientieu) { |
86 | + | double sovanthua, double sovanthang, double tienvon) { |
87 | - | Tientieu = tientieu; |
87 | + | super (name, phonenumber, address, songuoichoi, sovanthang, sovanthua, tienvon,sovanchoi); |
88 | this.Muoi = muoi; | |
89 | ||
90 | } | |
91 | - | package Programming.edu.oo; |
91 | + | |
92 | - | import java.text.ParseException; |
92 | + | public double getMuoi() { |
93 | - | import java.text.SimpleDateFormat; |
93 | + | return Muoi; |
94 | } | |
95 | - | import java.util.Date; |
95 | + | |
96 | public void setMuoi(double muoi) { | |
97 | - | import java.util.logging.Level; |
97 | + | Muoi = muoi; |
98 | - | import java.util.logging.Logger; |
98 | + | |
99 | double Tongtien(){ | |
100 | - | public class Truonghoc { |
100 | + | return getTienvon() + (getSovanthang()-getMuoi())*Thang + getMuoi()*2*Thang - getSovanthua()*Thua - getSovanchoi()*Tienga; |
101 | - | private ArrayList<Trunggian> Trunggians; |
101 | + | |
102 | - | private Scanner reader; |
102 | + | |
103 | } | |
104 | - | public Truonghoc() { |
104 | + | |
105 | - | Trunggians = new ArrayList<>(); |
105 | + | |
106 | - | reader = new Scanner(System.in); |
106 | + | package game; |
107 | ||
108 | public class Lieng extends Game { | |
109 | - | public Hocsinh nhapHocSinh() { |
109 | + | private double Lieng, Sap; |
110 | - | Hocsinh a = new Hocsinh(); |
110 | + | public Lieng(){ |
111 | - | System.out.println(" nhap ho va ten : "); |
111 | + | |
112 | - | a.setHoten(reader.nextLine()); |
112 | + | |
113 | - | System.out.println(" Nhap nam sinh : "); |
113 | + | public Lieng(double lieng, double sap, String name, String phonenumber, String address, double songuoichoi, double sovanchoi, double sovanthua, double sovanthang, double tienvon){ |
114 | - | a.setNamsinh(reader.nextLine()); |
114 | + | super(name, phonenumber, address, songuoichoi, sovanthang, sovanthua, tienvon,sovanchoi); |
115 | - | System.out.println(" Nhap Ma the : "); |
115 | + | this.Lieng = lieng; |
116 | - | a.setMathe(reader.nextLine()); |
116 | + | this.Sap = sap; |
117 | - | System.out.println(" nhap hoc phi con no : "); |
117 | + | |
118 | - | a.setHPno(reader.nextLine()); |
118 | + | |
119 | - | return a; |
119 | + | public double getLieng() { |
120 | return Lieng; | |
121 | } | |
122 | - | public Giaovien nhapGiaoVien() { |
122 | + | public void setLieng(double lieng) { |
123 | - | Giaovien b = new Giaovien(); |
123 | + | Lieng = lieng; |
124 | - | System.out.println(" nhap ho va ten : "); |
124 | + | |
125 | - | b.setHoten(reader.nextLine()); |
125 | + | public double getSap() { |
126 | - | System.out.println(" Nhap nam sinh : "); |
126 | + | return Sap; |
127 | - | b.setNamsinh(reader.nextLine()); |
127 | + | |
128 | - | System.out.println(" Nhap Ma the : "); |
128 | + | public void setSap(double sap) { |
129 | - | b.setMathe(reader.nextLine()); |
129 | + | Sap = sap; |
130 | - | System.out.println(" nhap tine luong : "); |
130 | + | |
131 | - | b.setTienluong(reader.nextLine()); |
131 | + | double Tongtien(){ |
132 | - | return b; |
132 | + | return getTienvon() + (getSovanthang() - getLieng() - getSap())*Thang + getLieng()*2*Thang + getSap()*3*Thang - getSovanthua()*Thua - getSovanchoi()*Tienga; |
133 | } | |
134 | ||
135 | - | public Giamdoc nhapGiamDoc() { |
135 | + | |
136 | - | Giamdoc c = new Giamdoc(); |
136 | + | |
137 | - | System.out.println(" nhap ho va ten : "); |
137 | + | |
138 | - | c.setHoten(reader.nextLine()); |
138 | + | package game; |
139 | - | System.out.println(" Nhap nam sinh : "); |
139 | + | |
140 | - | c.setNamsinh(reader.nextLine()); |
140 | + | |
141 | - | System.out.println(" Nhap Ma the : "); |
141 | + | |
142 | - | c.setMathe(reader.nextLine()); |
142 | + | |
143 | - | System.out.println(" nhap hoc phi con no : "); |
143 | + | public class Hoichoi { |
144 | - | c.setTientieu(reader.nextLine()); |
144 | + | private ArrayList<Game> Gamestart; |
145 | - | return c; |
145 | + | private Scanner reader; |
146 | public Hoichoi(){ | |
147 | Gamestart = new ArrayList<>(); | |
148 | - | private void nhapdanhsachtruong(){ |
148 | + | reader = new Scanner(System.in); |
149 | - | System.out.println(" nhap 1 - nhap Hoc Sinh"); |
149 | + | |
150 | - | System.out.println(" nhap 2 - nhap Giao Vien"); |
150 | + | } |
151 | - | System.out.println(" nhap 3 - nhap Giam Doc"); |
151 | + | private Bacay taoBacay(){ |
152 | - | int selectedValue; |
152 | + | Bacay bc= new Bacay(); |
153 | - | do { |
153 | + | System.out.println(" Nhap so nguoi choi : "); |
154 | - | System.out.println(" ban chon : "); |
154 | + | bc.setSonguoichoi(Double.parseDouble(reader.nextLine())); |
155 | - | selectedValue = Integer.parseInt(reader.nextLine()); |
155 | + | System.out.println(" Nhap ten nguoi choi : "); |
156 | - | |
156 | + | bc.setName(reader.nextLine()); |
157 | - | switch(selectedValue){ |
157 | + | System.out.println(" Nhap So dien thoai : "); |
158 | - | case 1: |
158 | + | bc.setPhonenumber(reader.nextLine()); |
159 | - | Trunggians .add(nhapHocSinh()); |
159 | + | System.out.println(" Nhap dia chi : "); |
160 | - | break ; |
160 | + | bc.setAddress(reader.nextLine()); |
161 | - | case 2 : |
161 | + | System.out.println(" Nhap so van choi : "); |
162 | - | Trunggians.add(nhapGiaoVien()); |
162 | + | bc.setSovanchoi(Double.parseDouble(reader.nextLine())); |
163 | - | break ; |
163 | + | System.out.println(" Nhap so van thua : "); |
164 | - | case 3 : |
164 | + | bc.setSovanthua(Double.parseDouble(reader.nextLine())); |
165 | - | Trunggians.add(nhapGiamDoc()); |
165 | + | System.out.println(" Nhap so van thang : "); |
166 | - | break ; |
166 | + | bc.setSovanthang(Double.parseDouble(reader.nextLine())); |
167 | - | } |
167 | + | System.out.println(" nhap so van duoc muoi :"); |
168 | - | } while (selectedValue!=4); |
168 | + | bc.setMuoi(Double.parseDouble(reader.nextLine())); |
169 | return bc; | |
170 | - | private void xuatdanhsachtruong(Trunggian trunggian){ |
170 | + | |
171 | - | System.out.println(" Ho Ten: "+trunggian.getHoten()); |
171 | + | } |
172 | - | System.out.println(" Nam Sinh : "+trunggian.getNamsinh()); |
172 | + | private Lieng taoLieng(){ |
173 | - | System.out.println(" Ma The : "+ trunggian.getMathe()); |
173 | + | Lieng l = new Lieng(); |
174 | - | Hocsinh hocsinh = (Hocsinh) trunggian; |
174 | + | System.out.println(" Nhap so nguoi choi : "); |
175 | - | System.out.println(" hoc sinh : "+hocsinh.getHoten()); |
175 | + | l.setSonguoichoi(Double.parseDouble(reader.nextLine())); |
176 | - | System.out.println(" nam sinh :"+hocsinh.getNamsinh()); |
176 | + | System.out.println(" Nhap ten nguoi choi : "); |
177 | - | System.out.println(" ma the : "+hocsinh.getMathe()); |
177 | + | l.setName(reader.nextLine()); |
178 | - | System.out.println(" hoc phi con no : "+hocsinh.getHPno()); |
178 | + | System.out.println(" Nhap So dien thoai : "); |
179 | - | Giaovien giaovien = (Giaovien) trunggian; |
179 | + | l.setPhonenumber(reader.nextLine()); |
180 | - | System.out.println(" giao vien : "+giaovien.getHoten()); |
180 | + | System.out.println(" Nhap dia chi : "); |
181 | - | System.out.println(" nam sinh : "+giaovien.getNamsinh()); |
181 | + | l.setAddress(reader.nextLine()); |
182 | - | System.out.println(" ma the : "+giaovien.getMathe()); |
182 | + | System.out.println(" Nhap so van choi : "); |
183 | - | System.out.println(" tien luong : "+giaovien.getTienluong()); |
183 | + | l.setSovanchoi(Double.parseDouble(reader.nextLine())); |
184 | - | Giamdoc giamdoc = (Giamdoc) trunggian; |
184 | + | System.out.println(" Nhap so van thua : "); |
185 | - | System.out.println(" giam doc : "+giamdoc.getHoten()); |
185 | + | l.setSovanthua(Double.parseDouble(reader.nextLine())); |
186 | - | System.out.println(" nam sinh : "+giamdoc.getNamsinh()); |
186 | + | System.out.println(" Nhap so van thang : "); |
187 | - | System.out.println(" ma the : "+giamdoc.getMathe()); |
187 | + | l.setSovanthang(Double.parseDouble(reader.nextLine())); |
188 | - | System.out.println(" tien tieu : "+giamdoc.getTientieu()); |
188 | + | System.out.println(" Nhap so van duoc lieng "); |
189 | l.setLieng(Double.parseDouble(reader.nextLine())); | |
190 | - | public static void main(String[]args){ |
190 | + | System.out.println(" Nhap so van sap : "); |
191 | - | Scanner input = new Scanner (System.in); |
191 | + | l.setSap(Double.parseDouble(reader.nextLine())); |
192 | return l; | |
193 | - | Truonghoc truonghoc = new Truonghoc(); |
193 | + | } |
194 | - | truonghoc.nhapdanhsachtruong(); |
194 | + | public void nhap(){ |
195 | - | truonghoc.xuatdanhsachtruong(); |
195 | + | System.out.println(" chon 1: choi Lieng "); |
196 | System.out.println(" chon 2: choi Ba Cay"); | |
197 | System.out.println(" chon 3: Finish"); | |
198 | int Game; | |
199 | do{ | |
200 | System.out.println(" Ban Chon !"); | |
201 | Game = Integer.parseInt(reader.nextLine()); | |
202 | switch(Game){ | |
203 | case 1 : | |
204 | Gamestart.add(taoLieng()); | |
205 | break; | |
206 | case 2 : | |
207 | Gamestart.add(taoBacay()); | |
208 | } | |
209 | }while(Game!=3); | |
210 | } | |
211 | public void xuat(Game G){ | |
212 | for(int i=0; i<Gamestart.size(); i++){ | |
213 | System.out.println(" Nhap so nguoi choi : "+G.getSonguoichoi()); | |
214 | System.out.println(" Nhap ten nguoi choi : "+G.getName()); | |
215 | System.out.println(" Nhap so dien thoai nguoi choi : "+G.getPhonenumber()); | |
216 | System.out.println(" Nhap Dia chi cua nguoi choi : "+G.getAddress()); | |
217 | System.out.println(" nhap so van choi : "+G.getSovanchoi()); | |
218 | System.out.println(" Nhap so van thang : "+G.getSovanthang()); | |
219 | System.out.println(" Nhap so van thua : " +G.getSovanthua()); | |
220 | if(G instanceof Lieng ){ | |
221 | Lieng l =(Lieng ) G; | |
222 | System.out.println(" So van duoc sap : "+l.getSap()); | |
223 | System.out.println(" So van duoc lieng : "+l.getLieng()); | |
224 | System.out.println(" So tien sau khi choi : "+l.Tongtien()); | |
225 | }else{ | |
226 | Bacay bc = (Bacay) G; | |
227 | System.out.println(" So van duoc 10 : "+bc.getMuoi()); | |
228 | System.out.println(" So tien sau khi choi : "+bc.Tongtien()); | |
229 | } | |
230 | ||
231 | } | |
232 | } | |
233 | public void xuat(){ | |
234 | for(Game G : Gamestart){ | |
235 | xuat(G); | |
236 | } | |
237 | } | |
238 | public static void main(String[]args){ | |
239 | Hoichoi choi = new Hoichoi(); | |
240 | choi.nhap(); | |
241 | choi.xuat(); | |
242 | } | |
243 | ||
244 | } |