Guest User

Untitled

a guest
Jun 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. public class Telephone {
  2. private int areaCode;
  3. private int threeDigitValue;
  4. private int fourDigitValue;
  5. private String username;
  6.  
  7. public Telephone(int areaCode, int threeDigitValue, int fourDigitValue, String username){
  8. this.areaCode = areaCode;
  9. this.threeDigitValue = threeDigitValue;
  10. this.fourDigitValue = fourDigitValue;
  11. this.username = username;
  12. }
  13.  
  14. public Telephone(){
  15. areaCode = 555;
  16. threeDigitValue = 555;
  17. fourDigitValue = 5555;
  18. username = null;
  19. }
  20.  
  21. public Telephone(Telephone teleToCopy) {
  22. this.areaCode = teleToCopy.getAreaCode();
  23. this.threeDigitValue = teleToCopy.getThreeDigitValue();
  24. this.fourDigitValue = teleToCopy.getFourDigitValue();
  25. this.username = teleToCopy.getUsername();
  26. }
  27.  
  28. public boolean equals(Telephone tele){
  29. if((this.areaCode == tele.getAreaCode()) &&
  30. (this.threeDigitValue == tele.getThreeDigitValue()) &&
  31. (this.fourDigitValue == tele.getFourDigitValue())){
  32. return true;
  33. }
  34. return false;
  35. }
  36.  
  37. public String toString(){
  38. return ("username: " + username +". phone number: " +
  39. areaCode+threeDigitValue+fourDigitValue);
  40. }
  41.  
  42. public void setAreaCode(int areaCodeIn){
  43. if(areaCodeIn > 99 && areaCodeIn < 1000){
  44. areaCode = areaCodeIn;
  45. }
  46. }
  47. public void setThreeDigitValue(int threeDigitValueIn){
  48. if(threeDigitValueIn > 99 && threeDigitValueIn < 1000){
  49. threeDigitValue = threeDigitValueIn;
  50. }
  51. }
  52.  
  53. public void setFourDigitValue(int fourDigitValueIn){
  54. if(fourDigitValueIn > 999 && fourDigitValueIn < 10000){
  55. fourDigitValue = fourDigitValueIn;
  56. }
  57. }
  58.  
  59. public void setUsername(String usernameIn){
  60. username = usernameIn;
  61. }
  62.  
  63.  
  64. public int getAreaCode(){
  65. return areaCode;
  66. }
  67. public int getThreeDigitValue(){
  68. return threeDigitValue;
  69. }
  70. public int getFourDigitValue(){
  71. return fourDigitValue;
  72. }
  73. public String getUsername(){
  74. return username;
  75. }
  76.  
  77. }
Add Comment
Please, Sign In to add comment