From e3827945c8bbd0bc39c49b16960da03360c851ee Mon Sep 17 00:00:00 2001 From: Besok Date: Sat, 26 Oct 2019 18:28:20 +0100 Subject: [PATCH] add changes --- .../roleobject/ApplicationRoleObject.java | 25 ++++++++++--------- .../com/iluwatar/roleobject/BorrowerRole.java | 3 +-- .../com/iluwatar/roleobject/InvestorRole.java | 3 +-- .../iluwatar/roleobject/BorrowerRoleTest.java | 2 +- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/role-object/src/main/java/com/iluwatar/roleobject/ApplicationRoleObject.java b/role-object/src/main/java/com/iluwatar/roleobject/ApplicationRoleObject.java index 1006fe084..b8296daba 100644 --- a/role-object/src/main/java/com/iluwatar/roleobject/ApplicationRoleObject.java +++ b/role-object/src/main/java/com/iluwatar/roleobject/ApplicationRoleObject.java @@ -36,25 +36,26 @@ import static com.iluwatar.roleobject.Role.*; * A subject often plays several roles and the same role is likely to * be played by different subjects. * As an example consider two different customers playing the role of borrower and - * investor, respectively. Both roles could as well be played by a single Customer object. - * The common superclass for customer-specific roles is provided by CustomerRole, - * which also supports the Customer interface. + * investor, respectively. Both roles could as well be played by a single {@link Customer} object. + * The common superclass for customer-specific roles is provided by {@link CustomerRole}, + * which also supports the {@link Customer} interface. *

- * The CustomerRole class is abstract and not meant to be instantiated. - * Concrete subclasses of CustomerRole, for example Borrower or Investor, + * The {@link CustomerRole} class is abstract and not meant to be instantiated. + * Concrete subclasses of {@link CustomerRole}, for example {@link BorrowerRole} or {@link InvestorRole}, * define and implement the interface for specific roles. It is only * these subclasses which are instantiated at runtime. - * The Borrower class defines the context-specific view of Customer objects as needed by the loan department. + * The {@link BorrowerRole} class defines the context-specific view of {@link Customer} objects as needed by the loan department. * It defines additional operations to manage the customer’s - * credits and securities. Similarly, the Investor class adds operations specific + * credits and securities. Similarly, the {@link InvestorRole} class adds operations specific * to the investment department’s view of customers. - * A client like the loan application may either work with objects of the CustomerCore class, using the interface class - * Customer, or with objects of concrete CustomerRole subclasses. Suppose the loan application knows a particular - * Customer instance through its Customer interface. The loan application may want to check whether the Customer + * A client like the loan application may either work with objects of the {@link CustomerRole} class, using the interface class + * {@link Customer}, or with objects of concrete {@link CustomerRole} subclasses. Suppose the loan application knows a particular + * {@link Customer} instance through its {@link Customer} interface. The loan application may want to check whether the {@link Customer} * object plays the role of Borrower. - * To this end it calls hasRole() with a suitable role specification. For the purpose of + * To this end it calls {@link Customer#hasRole(Role)} with a suitable role specification. For the purpose of * our example, let’s assume we can name roles with enum. - * If the Customer object can play the role named “Borrower,” the loan application will ask it to return a reference to the corresponding object. + * If the {@link Customer} object can play the role named “Borrower,” the loan application will ask it + * to return a reference to the corresponding object. * The loan application may now use this reference to call Borrower-specific operations. */ public class ApplicationRoleObject { diff --git a/role-object/src/main/java/com/iluwatar/roleobject/BorrowerRole.java b/role-object/src/main/java/com/iluwatar/roleobject/BorrowerRole.java index c48829a0a..425d9511d 100644 --- a/role-object/src/main/java/com/iluwatar/roleobject/BorrowerRole.java +++ b/role-object/src/main/java/com/iluwatar/roleobject/BorrowerRole.java @@ -34,8 +34,7 @@ public class BorrowerRole extends CustomerRole{ } public String borrow(){ - return String.join(" ", - "A borrower",name,"wants to get some money."); + return String.format("Borrower %s wants to get some money.",name); } } diff --git a/role-object/src/main/java/com/iluwatar/roleobject/InvestorRole.java b/role-object/src/main/java/com/iluwatar/roleobject/InvestorRole.java index 9f3ecdae3..6d5c17c90 100644 --- a/role-object/src/main/java/com/iluwatar/roleobject/InvestorRole.java +++ b/role-object/src/main/java/com/iluwatar/roleobject/InvestorRole.java @@ -43,7 +43,6 @@ public class InvestorRole extends CustomerRole { } public String invest() { - return String.join(" ", - "Investor", name, "has invested", String.valueOf(amountToInvest), "dollars"); + return String.format("Investor %s has invested %d dollars", name, amountToInvest); } } diff --git a/role-object/src/test/java/com/iluwatar/roleobject/BorrowerRoleTest.java b/role-object/src/test/java/com/iluwatar/roleobject/BorrowerRoleTest.java index 1641e20fa..0c0f92fc2 100644 --- a/role-object/src/test/java/com/iluwatar/roleobject/BorrowerRoleTest.java +++ b/role-object/src/test/java/com/iluwatar/roleobject/BorrowerRoleTest.java @@ -33,7 +33,7 @@ public class BorrowerRoleTest { public void borrowTest() { BorrowerRole borrowerRole = new BorrowerRole(); borrowerRole.setName("test"); - String res = "A borrower test wants to get some money."; + String res = "Borrower test wants to get some money."; Assert.assertEquals(borrowerRole.borrow(),res); }