/src/elements/ProfessionFactory.java

http://inequity.googlecode.com/ · Java · 604 lines · 106 code · 37 blank · 461 comment · 0 complexity · 21564ac729124b04c61711b60e1f2086 MD5 · raw file

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