Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Telephone {
- private int areaCode;
- private int threeDigitValue;
- private int fourDigitValue;
- private String username;
- public Telephone(int areaCode, int threeDigitValue, int fourDigitValue, String username){
- this.areaCode = areaCode;
- this.threeDigitValue = threeDigitValue;
- this.fourDigitValue = fourDigitValue;
- this.username = username;
- }
- public Telephone(){
- areaCode = 555;
- threeDigitValue = 555;
- fourDigitValue = 5555;
- username = null;
- }
- public Telephone(Telephone teleToCopy) {
- this.areaCode = teleToCopy.getAreaCode();
- this.threeDigitValue = teleToCopy.getThreeDigitValue();
- this.fourDigitValue = teleToCopy.getFourDigitValue();
- this.username = teleToCopy.getUsername();
- }
- public boolean equals(Telephone tele){
- if((this.areaCode == tele.getAreaCode()) &&
- (this.threeDigitValue == tele.getThreeDigitValue()) &&
- (this.fourDigitValue == tele.getFourDigitValue())){
- return true;
- }
- return false;
- }
- public String toString(){
- return ("username: " + username +". phone number: " +
- areaCode+threeDigitValue+fourDigitValue);
- }
- public void setAreaCode(int areaCodeIn){
- if(areaCodeIn > 99 && areaCodeIn < 1000){
- areaCode = areaCodeIn;
- }
- }
- public void setThreeDigitValue(int threeDigitValueIn){
- if(threeDigitValueIn > 99 && threeDigitValueIn < 1000){
- threeDigitValue = threeDigitValueIn;
- }
- }
- public void setFourDigitValue(int fourDigitValueIn){
- if(fourDigitValueIn > 999 && fourDigitValueIn < 10000){
- fourDigitValue = fourDigitValueIn;
- }
- }
- public void setUsername(String usernameIn){
- username = usernameIn;
- }
- public int getAreaCode(){
- return areaCode;
- }
- public int getThreeDigitValue(){
- return threeDigitValue;
- }
- public int getFourDigitValue(){
- return fourDigitValue;
- }
- public String getUsername(){
- return username;
- }
- }
Add Comment
Please, Sign In to add comment