1
0
Fork 0

Merge branch 'master' into 'reading'

# Conflicts:
#   src/noteBook/NoteBook.java
This commit is contained in:
Ethanell 2020-04-04 15:53:54 +02:00
commit 01ac0bca4c
4 changed files with 59 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package input; package input;
import java.security.KeyStore;
public class Person implements Input{ public class Person implements Input{
public String lastName; public String lastName;
public String firstName[]; public String firstName[];
@ -61,6 +63,12 @@ public class Person implements Input{
@Override @Override
public boolean research(String search) { public boolean research(String search) {
if (lastName.equals(search))
return true;
else
for (String s: firstName)
if (s.equals(search))
return true;
return false; return false;
} }
} }

View file

@ -15,6 +15,6 @@ public class Society implements Input{
@Override @Override
public boolean research(String search) { public boolean research(String search) {
return false; return socialReason.equals(search);
} }
} }

View file

@ -4,7 +4,6 @@ import input.Gender;
import input.Input; import input.Input;
import input.Person; import input.Person;
import input.Society; import input.Society;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Scanner; import java.util.Scanner;
@ -47,3 +46,39 @@ public class NoteBook {
} }
} }
} }
public void addInput(Input in) {
Input[] tmp = new Input[inputs.length+1];
System.arraycopy(inputs, 0, tmp, 0, inputs.length);
tmp[inputs.length] = in;
inputs = tmp;
}
public void select(String selected) {
for (Input i: inputs)
if (i.toString().equals(selected)) {
this.selected = new Input[]{i};
break;
}
}
public void select(Input selected) {
this.selected = new Input[]{selected};
}
public void select(Input[] selected) {
this.selected = selected;
}
public Input[] research(String target) {
Input[] tmp = new Input[inputs.length];
int index = 0;
for (Input i: inputs) {
if (i.research(target))
tmp[index++] = i;
}
Input[] out = new Input[index];
System.arraycopy(tmp, 0, out, 0, out.length);
return out;
}
}

View file

@ -0,0 +1,13 @@
package test;
import input.Input;
import noteBook.NoteBook;
public class TestSelection {
public static void main(String[] args) {
NoteBook book = new NoteBook();
book.FileReading("testBook");
for (Input i: book.inputs)
System.out.println(i);
}
}