Last active
September 12, 2022 22:40
-
-
Save trikitrok/405a11e8fa703c4a96192b6b3a7d5bd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From Ayush Jindal's exercises for code smells https://github.com/ayjindal/CodeSmells | |
public class Customer { | |
private String name; | |
private Address currentAddress; | |
public Customer(String name, Address address) { | |
this.name = name; | |
this.currentAddress = address; | |
} | |
public void printAddress() { | |
System.out.println( | |
currentAddress.getAddressLine1() + "\n" + currentAddress.getAddressLine2() + "\n" + | |
currentAddress.getCity() + ", " + currentAddress.getState() + "\n" + | |
currentAddress.getPostalCode()); | |
} | |
//other methods in customer class..... | |
} | |
public class Address { | |
private String addressLine1; | |
private String addressLine2; | |
private String city; | |
private String state; | |
private String country; | |
private String postalCode; | |
public Address(String addressLine1, String addressLine2, String city, String state, | |
String country, String postalCode) { | |
this.addressLine1 = addressLine1; | |
this.addressLine2 = addressLine2; | |
this.city = city; | |
this.state = state; | |
this.country = country; | |
this.postalCode = postalCode; | |
} | |
public String getAddressLine1() { | |
return addressLine1; | |
} | |
public String getAddressLine2() { | |
return addressLine2; | |
} | |
public String getCity() { | |
return city; | |
} | |
public String getState() { | |
return state; | |
} | |
public String getCountry() { | |
return country; | |
} | |
public String getPostalCode() { | |
return postalCode; | |
} | |
} | |
//---------------------------------------------------------------------------- | |
//---------------------------------------------------------------------------- | |
public class Address { | |
private String addressLine1; | |
private String addressLine2; | |
private String city; | |
private String state; | |
private String country; | |
private String postalCode; | |
public Address(String addressLine1, String addressLine2, String city, String state, | |
String country, String postalCode) { | |
this.addressLine1 = addressLine1; | |
this.addressLine2 = addressLine2; | |
this.city = city; | |
this.state = state; | |
this.country = country; | |
this.postalCode = postalCode; | |
} | |
public String toString() { | |
return addressLine1 + "\n" + addressLine2 + "\n" + | |
city + ", " + state + "\n" + postalCode; | |
} | |
} | |
public class Customer { | |
private String name; | |
private Address currentAddress; | |
public Customer(String name, Address address) { | |
this.name = name; | |
this.currentAddress = address; | |
} | |
public void printAddress() { | |
System.out.println(currentAddress.toString()); | |
} | |
//other methods in customer class..... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment