Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- class Human{
- String name; // attributes
- Phone[] phones = new Phone[5];
- int numOfPhone = 0;
- public Human(String name){ // constructor
- this.name = name;
- }
- // methods
- void addPhone(Phone phone){
- if(this.numOfPhone < 5){
- this.phones[numOfPhone] = phone;
- this.numOfPhone += 1;
- }else{
- System.out.println("Adding of a new phone is not allowed.");
- }
- void call(int phoneNumber){
- phones[phoneNumber].call();
- }
- void text(int phoneNumber){
- phones[phoneNumber].text();
- }
- void addSimToPhone(int phoneNumber, SimCard simcard){
- phones[phoneNumber].addSim(simcard);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement