Advertisement
tjhlsn

Untitled

Feb 22nd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. class Human{
  4. String name; // attributes
  5. Phone[] phones = new Phone[5];
  6. int numOfPhone = 0;
  7.  
  8. public Human(String name){ // constructor
  9. this.name = name;
  10. }
  11.  
  12. // methods
  13.  
  14. void addPhone(Phone phone){
  15. if(this.numOfPhone < 5){
  16. this.phones[numOfPhone] = phone;
  17. this.numOfPhone += 1;
  18. }else{
  19. System.out.println("Adding of a new phone is not allowed.");
  20. }
  21.  
  22. void call(int phoneNumber){
  23. phones[phoneNumber].call();
  24. }
  25.  
  26. void text(int phoneNumber){
  27. phones[phoneNumber].text();
  28. }
  29.  
  30. void addSimToPhone(int phoneNumber, SimCard simcard){
  31. phones[phoneNumber].addSim(simcard);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement