PageRenderTime 64ms CodeModel.GetById 39ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 0ms

/src/elements/ProfessionFactory.java

http://inequity.googlecode.com/
Java | 604 lines | 106 code | 37 blank | 461 comment | 0 complexity | 21564ac729124b04c61711b60e1f2086 MD5 | raw file
  1package elements;
  2
  3import elements.ProfessionFactory.profession_type;
  4import java.util.HashMap;
  5import java.util.Random;
  6
  7/**
  8 * ProfessionFactory initializer
  9 * @author Joel Garboden
 10 * Contains the definitions for individual professions inside a wrapper class
 11 */
 12public class ProfessionFactory
 13{
 14  public static final double BASE_TAX_RATE = 0.095;
 15  public static final double BASE_HOUSE_RATE = 0.089;
 16  public static final double BASE_CAR_RATE = 0.089;
 17  public static final double BASE_CARD_RATE = 0.089;
 18  public static final double BASE_LOAN_RATE = 0.089;
 19  public static final int BASE_LIVING_EXPENSE = 200;
 20
 21  public static final double GENERIC_CARD_INTEREST_CHANGE = 0.05;
 22
 23  public static final int MINOR_DEMOTION_PROMOTION = 1;
 24  public static final int MODERATE_DEMOTION_PROMOTION = 5;
 25  public static final int MAJOR_DEMOTION_PROMOTION = 10;
 26  public static final int MASSIVE_DEMOTION_PROMOTION = 20;
 27
 28  /**
 29   *
 30   */
 31  public enum profession_type {PILOT, ENTREPENEUR};
 32//                                DOCTOR, ENGINEER, JANITOR,
 33//                               LAWYER, MECHANIC, NURSE, COP, SECRETARY, TEACHER,
 34//                               DRIVER};
 35
 36  private static HashMap professionList;
 37
 38  public ProfessionFactory()
 39  {
 40    professionList = new HashMap();   //<profession_type,Profession>();
 41    professionList.put(profession_type.PILOT, new Pilot());
 42    professionList.put(profession_type.ENTREPENEUR, new Entrepreneur());
 43    /* //TODO implement the rest of the professions
 44    professionList.add(new Doctor());
 45    professionList.add(new Engineer());
 46    professionList.add(new Janitor());
 47    professionList.add(new Mechanic());
 48    professionList.add(new Nurse());
 49    professionList.add(new Cop());
 50    professionList.add(new Secretary());
 51    professionList.add(new Teacher());
 52    professionList.add(new Driver());
 53    */
 54  }
 55
 56  /**
 57   *
 58   * @return
 59   */
 60  public static profession_type getRandomProfessionID()
 61  {
 62    Random r = new Random();
 63
 64    int randomProf = r.nextInt(professionList.size());
 65
 66    return profession_type.values()[randomProf];
 67  }
 68
 69  public abstract class Profession
 70  {
 71    /**
 72     *
 73     * @param portfolio
 74     */
 75    public abstract void setProfession(PlayerPortfolio portfolio);
 76  }
 77
 78  /**
 79   *
 80   * @param profType
 81   * @param playerName
 82   * @return profession index is (in)valid
 83   */
 84  public PlayerPortfolio makePortfolioFor(profession_type profType, String playerName)
 85  {
 86    PlayerPortfolio portfolio = new PlayerPortfolio(playerName);
 87    Profession prof = (Profession) professionList.get(profType);
 88    prof.setProfession(portfolio);
 89    return portfolio;
 90  }
 91
 92  /**
 93   *
 94   */
 95  public class Pilot extends Profession
 96  {
 97    public static final int INIT_CASH = 3000;
 98    /**
 99     *
100     * @param portfolio
101     */
102    @Override
103    public void setProfession(PlayerPortfolio portfolio)
104    {
105      portfolio.profession = "Pilot";
106      portfolio.moneyIn(INIT_CASH);
107      portfolio.paycheckAmount = 2600;
108      portfolio.payWeek = 1;
109
110      portfolio.salary = 9500;
111
112      portfolio.monthlyTaxes = 2350;
113      portfolio.taxInterestRate = BASE_TAX_RATE;
114
115      portfolio.monthlyHousePayment = 1330;
116      portfolio.houseInterestRate = BASE_HOUSE_RATE;
117
118      portfolio.monthlySchoolPayment = 0;
119      portfolio.monthlyCarPayment = 300;
120      portfolio.carInterestRate = BASE_CAR_RATE;
121
122      portfolio.monthlyCardPayment = 660;
123      portfolio.cardInterestRate = BASE_CARD_RATE;
124
125      portfolio.monthlyLoanInterestRate = BASE_LOAN_RATE;
126
127      portfolio.weeklyRetailPayment = 50;
128      portfolio.weeklyMiscPayment = 2210;
129
130      portfolio.monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
131
132      portfolio.weeklyCostPerChild = 480;
133
134      portfolio.remainingHousePayment = 143000;
135      portfolio.remainingSchoolPayment = 0;
136      portfolio.remainingCarPayment = 15000;
137      portfolio.chargeCard(22000); //remainingCardPayment
138
139      portfolio.prof_ID = profession_type.PILOT;
140    }
141  }
142
143  /**
144   * Initialization data for Business Entrepreneur profession
145   */
146  public class Entrepreneur extends Profession
147  {
148    public static final int INIT_CASH = 2070;
149    /**
150     *
151     * @param portfolio
152     */
153    @Override
154    public void setProfession(PlayerPortfolio portfolio)
155    {
156      portfolio.profession = "Entrepeneur";
157      portfolio.moneyIn(INIT_CASH);
158      portfolio.paycheckAmount = 1670;
159      portfolio.payWeek = 1;
160
161      portfolio.salary = 4600;
162
163      portfolio.monthlyTaxes = 910;
164      portfolio.taxInterestRate = BASE_TAX_RATE;
165
166      portfolio.monthlyHousePayment = 700;
167      portfolio.houseInterestRate = BASE_HOUSE_RATE;
168
169      portfolio.monthlySchoolPayment = 60;
170      portfolio.monthlyCarPayment = 120;
171      portfolio.carInterestRate = BASE_CAR_RATE;
172
173      portfolio.monthlyCardPayment = 90;
174      portfolio.cardInterestRate = BASE_CARD_RATE;
175
176      portfolio.weeklyRetailPayment = 50;
177      portfolio.weeklyMiscPayment = 1000;
178
179      portfolio.weeklyCostPerChild = 240;
180
181      portfolio.monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
182
183      portfolio.remainingHousePayment = 75000;
184      portfolio.remainingSchoolPayment = 12000;
185      portfolio.remainingCarPayment = 6000;
186      portfolio.chargeCard(3000); //remainingCardPayment
187
188      portfolio.prof_ID = profession_type.ENTREPENEUR;
189    }
190  }
191
192
193  /**
194   * Initialization data for Doctor profession
195   */
196  /*
197  public void setAsDoctor()
198  {
199    professionName = "Doctor";
200    cash = 3950;
201    paycheckAmount = 3550;
202    payWeek = 1;
203
204    salary = 13200;
205
206    monthlyTaxes = 3420;
207    taxInterestRate = BASE_TAX_RATE;
208
209    monthlyHousePayment = 1900;
210    houseInterestRate = BASE_HOUSE_RATE;
211
212    monthlySchoolPayment = 750;
213    monthlyCarPayment = 380;
214    carInterestRate = BASE_CAR_RATE;
215
216    monthlyCardPayment = 270;
217    cardInterestRate = BASE_CARD_RATE;
218
219    weeklyRetailPayment = 50;
220    weeklyMiscPayment = 2880;
221
222    weeklyCostPerChild = 640;
223
224    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
225
226    remainingHousePayment = 202000;
227    remainingSchoolPayment = 150000;
228    remainingCarPayment = 19000;
229    remainingCardPayment = 9000;
230
231    prof_ID = profession_type.DOCTOR;
232  }
233
234  /**
235   * Initialization data for Engineer profession
236   */
237  /*
238  public void setAsEngineer()
239  {
240    professionName = "Engineer";
241    cash = 2090;
242    paycheckAmount = 1690;
243    payWeek = 1;
244
245    salary = 4900;
246
247    monthlyTaxes = 1000;
248    taxInterestRate = BASE_TAX_RATE;
249
250    monthlyHousePayment = 700;
251    houseInterestRate = BASE_HOUSE_RATE;
252
253    monthlySchoolPayment = 60;
254    monthlyCarPayment = 140;
255    carInterestRate = BASE_CAR_RATE;
256
257    monthlyCardPayment = 120;
258    cardInterestRate = BASE_CARD_RATE;
259
260    weeklyRetailPayment = 50;
261    weeklyMiscPayment = 1090;
262
263    weeklyCostPerChild = 250;
264
265    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
266
267    remainingHousePayment = 75000;
268    remainingSchoolPayment = 12000;
269    remainingCarPayment = 7000;
270    remainingCardPayment = 4000;
271
272    prof_ID = profession_type.ENGINEER;
273  }
274
275  /**
276   * Initialization data for Janitor profession
277   */
278  /*
279  public void setAsJanitor()
280  {
281    professionName = "Janitor";
282    cash = 1110;
283    paycheckAmount = 650;
284    payWeek = 1;
285
286    salary = 1600;
287
288    monthlyTaxes = 280;
289    taxInterestRate = BASE_TAX_RATE;
290
291    monthlyHousePayment = 200;
292    houseInterestRate = BASE_HOUSE_RATE;
293
294    monthlySchoolPayment = 0;
295    monthlyCarPayment = 60;
296    carInterestRate = BASE_CAR_RATE;
297
298    monthlyCardPayment = 60;
299    cardInterestRate = BASE_CARD_RATE;
300
301    weeklyRetailPayment = 50;
302    weeklyMiscPayment = 300;
303
304    weeklyCostPerChild = 70;
305
306    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
307
308    remainingHousePayment = 20000;
309    remainingSchoolPayment = 0;
310    remainingCarPayment = 4000;
311    remainingCardPayment = 2000;
312
313    prof_ID = profession_type.JANITOR;
314  }
315
316  /**
317   * Initialization data for Lawyer profession
318   */
319  /*
320  public void setAsLawyer()
321  {
322    professionName = "Lawyer";
323    cash = 2480;
324    paycheckAmount = 2080;
325    payWeek = 1;
326
327    salary = 7500;
328
329    monthlyTaxes = 1830;
330    taxInterestRate = BASE_TAX_RATE;
331
332    monthlyHousePayment = 1100;
333    houseInterestRate = BASE_HOUSE_RATE;
334
335    monthlySchoolPayment = 390;
336    monthlyCarPayment = 220;
337    carInterestRate = BASE_CAR_RATE;
338
339    monthlyCardPayment = 180;
340    cardInterestRate = BASE_CARD_RATE;
341
342    weeklyRetailPayment = 50;
343    weeklyMiscPayment = 1650;
344
345    weeklyCostPerChild = 380;
346
347    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
348
349    remainingHousePayment = 115000;
350    remainingSchoolPayment = 78000;
351    remainingCarPayment = 11000;
352    remainingCardPayment = 6000;
353
354    prof_ID = profession_type.LAWYER;
355  }
356
357  /**
358   * Initialization data for Mechanic profession
359   */
360  /*
361  public void setAsMechanic()
362  {
363    professionName = "Mechanic";
364    cash = 1390;
365    paycheckAmount = 720;
366    payWeek = 1;
367
368    salary = 2000;
369
370    monthlyTaxes = 360;
371    taxInterestRate = BASE_TAX_RATE;
372
373    monthlyHousePayment = 300;
374    houseInterestRate = BASE_HOUSE_RATE;
375
376    monthlySchoolPayment = 0;
377    monthlyCarPayment = 60;
378    carInterestRate = BASE_CAR_RATE;
379
380    monthlyCardPayment = 60;
381    cardInterestRate = BASE_CARD_RATE;
382
383    weeklyRetailPayment = 50;
384    weeklyMiscPayment = 450;
385
386    weeklyCostPerChild = 110;
387
388    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
389
390    remainingHousePayment = 31000;
391    remainingSchoolPayment = 0;
392    remainingCarPayment = 3000;
393    remainingCardPayment = 2000;
394
395    prof_ID = profession_type.MECHANIC;
396  }
397
398  /**
399   * Initialization data for Nurse profession
400   */
401  /*
402  public void setAsNurse()
403  {
404    professionName = "Nurse";
405    cash = 1700;
406    paycheckAmount = 1120;
407    payWeek = 1;
408
409    salary = 3100;
410
411    monthlyTaxes = 600;
412    taxInterestRate = BASE_TAX_RATE;
413
414    monthlyHousePayment = 400;
415    houseInterestRate = BASE_HOUSE_RATE;
416
417    monthlySchoolPayment = 30;
418    monthlyCarPayment = 100;
419    carInterestRate = BASE_CAR_RATE;
420
421    monthlyCardPayment = 90;
422    cardInterestRate = BASE_CARD_RATE;
423
424    weeklyRetailPayment = 50;
425    weeklyMiscPayment = 710;
426
427    weeklyCostPerChild = 170;
428
429    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
430
431    remainingHousePayment = 47000;
432    remainingSchoolPayment = 6000;
433    remainingCarPayment = 5000;
434    remainingCardPayment = 3000;
435
436    prof_ID = profession_type.NURSE;
437    }
438
439  /**
440   * Initialization data for Police Officer profession
441   */
442  /*
443  public void setAsPoliceOfficer()
444  {
445    /*
446    professionName = "Police Officer";
447    cash = 1640;
448    paycheckAmount = 1120;
449    payWeek = 1;
450
451    salary = 3000;
452
453    monthlyTaxes = 580;
454    taxInterestRate = BASE_TAX_RATE;
455
456    monthlyHousePayment = 400;
457    houseInterestRate = BASE_HOUSE_RATE;
458
459    monthlySchoolPayment = 0;
460    monthlyCarPayment = 100;
461    carInterestRate = BASE_CAR_RATE;
462
463    monthlyCardPayment = 60;
464    cardInterestRate = BASE_CARD_RATE;
465
466    weeklyRetailPayment = 50;
467    weeklyMiscPayment = 690;
468
469    weeklyCostPerChild = 160;
470
471    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
472
473    remainingHousePayment = 46000;
474    remainingSchoolPayment = 0;
475    remainingCarPayment = 5000;
476    remainingCardPayment = 2000;
477
478    prof_ID = profession_type.COP;
479  }
480
481  /**
482   * Initialization data for Secretary profession
483   */
484    /*
485  public void setAsSecretary()
486  {
487    professionName = "Secretary";
488    cash = 1590;
489    paycheckAmount = 880;
490    payWeek = 1;
491
492    salary = 2500;
493
494    monthlyTaxes = 460;
495    taxInterestRate = BASE_TAX_RATE;
496
497    monthlyHousePayment = 400;
498    houseInterestRate = BASE_HOUSE_RATE;
499
500    monthlySchoolPayment = 0;
501    monthlyCarPayment = 80;
502    carInterestRate = BASE_CAR_RATE;
503
504    monthlyCardPayment = 60;
505    cardInterestRate = BASE_CARD_RATE;
506
507    weeklyRetailPayment = 50;
508    weeklyMiscPayment = 570;
509
510    weeklyCostPerChild = 140;
511
512    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
513
514    remainingHousePayment = 38000;
515    remainingSchoolPayment = 0;
516    remainingCarPayment = 4000;
517    remainingCardPayment = 2000;
518
519    prof_ID = profession_type.SECRETARY;
520  }
521
522  /**
523   * Initialization data for Teacher profession
524   */
525    /*
526  public void setAsTeacher()
527  {
528    professionName = "Teacher";
529    cash = 1510;
530    paycheckAmount = 1110;
531    payWeek = 1;
532
533    salary = 3300;
534
535    monthlyTaxes = 630;
536    taxInterestRate = BASE_TAX_RATE;
537
538    monthlyHousePayment = 500;
539    houseInterestRate = BASE_HOUSE_RATE;
540
541    monthlySchoolPayment = 60;
542    monthlyCarPayment = 100;
543    carInterestRate = BASE_CAR_RATE;
544
545    monthlyCardPayment = 90;
546    cardInterestRate = BASE_CARD_RATE;
547
548    weeklyRetailPayment = 50;
549    weeklyMiscPayment = 760;
550
551    weeklyCostPerChild = 180;
552
553    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
554
555    remainingHousePayment = 50000;
556    remainingSchoolPayment = 12000;
557    remainingCarPayment = 5000;
558    remainingCardPayment = 3000;
559
560    prof_ID = profession_type.TEACHER;
561  }
562
563  /**
564   * Initialization data for Truck Driver profession
565   */
566    /*
567  public void setAsTruckDriver()
568  {
569    professionName = "Truck Driver";
570    cash = 1630;
571    paycheckAmount = 880;
572    payWeek = 1;
573
574    salary = 2500;
575
576    monthlyTaxes = 460;
577    taxInterestRate = BASE_TAX_RATE;
578
579    monthlyHousePayment = 400;
580    houseInterestRate = BASE_HOUSE_RATE;
581
582    monthlySchoolPayment = 0;
583    monthlyCarPayment = 80;
584    carInterestRate = BASE_CAR_RATE;
585
586    monthlyCardPayment = 60;
587    cardInterestRate = BASE_CARD_RATE;
588
589    weeklyRetailPayment = 50;
590    weeklyMiscPayment = 570;
591
592    weeklyCostPerChild = 480;
593
594    monthlyLivingExpensePayment = BASE_LIVING_EXPENSE;
595
596    remainingHousePayment = 143000;
597    remainingSchoolPayment = 0;
598    remainingCarPayment = 15000;
599    remainingCardPayment = 22000;
600
601    prof_ID = profession_type.DRIVER;
602  }
603*/
604}