BAEL-3966: find object's class in Java (#9118)

This commit is contained in:
Aaron Juarez
2020-04-25 16:23:13 -04:00
committed by GitHub
parent a2e8282015
commit e1e47ffe6a
4 changed files with 129 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
package com.baeldung.objectclass;
import lombok.Data;
@Data
public class Borrower extends User {
private double totalLoanAmount;
public double requestLoan(double amount) {
totalLoanAmount = amount;
return totalLoanAmount;
}
public double increaseLoan(double increaseBy) {
return totalLoanAmount + increaseBy;
}
public double payLoan(double amount) {
return totalLoanAmount - amount;
}
}

View File

@@ -0,0 +1,20 @@
package com.baeldung.objectclass;
public class Lender extends User {
private double totalInvestmentAmount;
public double invest(double amount) {
totalInvestmentAmount = amount;
return totalInvestmentAmount;
}
public double increaseInvestment(double increaseBy) {
return totalInvestmentAmount + increaseBy;
}
public double collectDividends() {
return totalInvestmentAmount * 0.07;
}
}

View File

@@ -0,0 +1,12 @@
package com.baeldung.objectclass;
import lombok.Data;
@Data
public class User {
private String firstName;
private String lastName;
}