Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2013 13:23
Show Gist options
  • Save anonymous/5452091 to your computer and use it in GitHub Desktop.
Save anonymous/5452091 to your computer and use it in GitHub Desktop.
import java.util.ArrayList; ///////////////////////// public class orej { //private String nazov; // private int kapacita = 5; private ArrayList<Employee> emp; public orej() { //this.nazov = nazov; this.emp = new ArrayList(); } ///////////////////////// public boolean pridajEmp(Employee e) { return this.emp.add(e); } public void vypisZoznam() { …
import java.util.ArrayList;
/////////////////////////
public class orej {
//private String nazov;
// private int kapacita = 5;
private ArrayList<Employee> emp;
public orej() {
//this.nazov = nazov;
this.emp = new ArrayList();
}
/////////////////////////
public boolean pridajEmp(Employee e) {
return this.emp.add(e);
}
public void vypisZoznam() {
if (this.emp.isEmpty()) {
System.out.print("zaznam je prazydny");
} else {
for (Employee e : this.emp) {
e.vypis();
}
}
}
/**
*
* @param index
* @return
*/
public boolean odoberEmp(int index) {
if (this.emp.isEmpty()) {
System.out.println("chyba:zoznam je prazdny");
return false;
} else if (this.emp.size() <= index) {
System.out.println("zadany index je neplatny");
return false;
} else {
this.emp.remove(index);
return true;
}
}
public Employee ziskajEmp(int index){
return this.emp.get(index);
}
public int vratIndex(Employee e){
for(int i=0;i<this.emp.size();i++){
Employee etemp = this.ziskajEmp(i);
if(e.equals(etemp)){
return i;
}
}
return -1;
}
public boolean hladajEmp(Employee e){
return this.emp.contains(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment