Advertisement
tjhlsn

Untitled

Feb 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. /***********************************************************
  2. * @author Hannah Faith M. Halasan
  3. * @created_date 2017-02-20 20:30
  4. *
  5. ***********************************************************/
  6.  
  7. import java.util.Arrays;
  8.  
  9. class Human{
  10. String name; // attributes
  11. Phone[] phones = new Phone[5];
  12. int numOfPhone = 0;
  13.  
  14. public Human(String name){ // constructor
  15. this.name = name;
  16. }
  17.  
  18. // methods
  19.  
  20. void addPhone(Phone phone){
  21. if(this.numOfPhone < 5){
  22. this.phones[numOfPhone] = phone;
  23. this.numOfPhone += 1;
  24. }else{
  25. System.out.println("Adding of a new phone is not allowed.");
  26. }
  27. }
  28.  
  29. void call(int phoneNumber){
  30. phones[phoneNumber].call();
  31. }
  32.  
  33. void text(int phoneNumber){
  34. phones[phoneNumber].text();
  35. }
  36.  
  37. void addSimToPhone(int phoneNumber, SimCard simcard){
  38. phones[phoneNumber].addSim(simcard);
  39. }
  40. void viewState(){
  41. System.out.println("The phone number " + this.phoneNumber + " of " + this.name + " has a SIM card of " + simcard.network + " and a phone number of " + simcard.number + ". The current battery level of the phone is " + phone.battery + "%."); /* di ko na alam rip */
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement