Advertisement
vallec

Client

Jan 24th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. public class Client extends Credit{
  2.  
  3. private String firstName;
  4. private String lastName;
  5. private int age;
  6. private double budget;
  7. private int repaymentTime;
  8.  
  9. public Client(CreditType creditType, String firstName, String lastName, int age, double budget, int repaymentTime) {
  10. super(creditType);
  11. this.firstName = firstName;
  12. this.lastName = lastName;
  13. setAge(age);
  14. this.budget = budget;
  15. setRepaymentTime(repaymentTime);
  16. }
  17.  
  18. public String getFirstName() {
  19. return this.firstName;
  20. }
  21.  
  22. public String getLastName( ) {
  23. return this.lastName;
  24. }
  25.  
  26. public void setAge(int age) {
  27. if (age < 18 || age > 90) {
  28. throw new IllegalArgumentException("Cannot give credit to that person");
  29. } else {
  30. this.age = age;
  31. }
  32. }
  33.  
  34. public int getAge() {
  35. return this.age;
  36. }
  37.  
  38. public double getBudget() {
  39. return this.budget;
  40. }
  41.  
  42. public void setRepaymentTime(int repaymentTime) {
  43. if (repaymentTime < 3) {
  44. throw new IllegalArgumentException("Repayment time too low");
  45. }
  46. else {
  47. this.repaymentTime = repaymentTime;
  48. }
  49. }
  50.  
  51. public int getRepaymentTime() {
  52. return this.repaymentTime;
  53. }
  54.  
  55.  
  56. }
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement