Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Office {
- private int amount;
- private String[] people;
- private String location;
- public Office(String location, int n){
- amount=0;
- if(n<0){
- people = new String[0];
- }
- else if(n>0){
- people = new String[n];
- }
- this.location=location;
- }
- public String getLocation(){
- return location;
- }
- public String[] getPeople(){
- return people;
- }
- public void addPerson(String p){
- if(amount > people.length){
- throw new ArrayIndexOutOfBoundsException();
- }
- people[amount]=p;
- amount++;
- }
- public void replacePerson(String replace, String with){
- for(int i=0;i<amount;i++){
- if(people[i].compareTo(replace) == 0){
- people[i]=with;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement