Merge branch 'master' into 'reading'
# Conflicts: # src/noteBook/NoteBook.java
This commit is contained in:
commit
01ac0bca4c
4 changed files with 59 additions and 3 deletions
|
@ -1,5 +1,7 @@
|
|||
package input;
|
||||
|
||||
import java.security.KeyStore;
|
||||
|
||||
public class Person implements Input{
|
||||
public String lastName;
|
||||
public String firstName[];
|
||||
|
@ -61,6 +63,12 @@ public class Person implements Input{
|
|||
|
||||
@Override
|
||||
public boolean research(String search) {
|
||||
if (lastName.equals(search))
|
||||
return true;
|
||||
else
|
||||
for (String s: firstName)
|
||||
if (s.equals(search))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ public class Society implements Input{
|
|||
|
||||
@Override
|
||||
public boolean research(String search) {
|
||||
return false;
|
||||
return socialReason.equals(search);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import input.Gender;
|
|||
import input.Input;
|
||||
import input.Person;
|
||||
import input.Society;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
13
src/test/TestSelection.java
Normal file
13
src/test/TestSelection.java
Normal 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);
|
||||
}
|
||||
}
|
Reference in a new issue