Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- public class Search implements InsertAndSearch {
- private int capacity = 10;
- int[] Array = new int[capacity];
- int[] Last = new int[5];
- public void expandCapacity() {
- int[] temp = new int[Array.length * 2];
- for (int i = 0; i < Array.length; i++) {
- temp[i] = Array[i];
- }
- }
- public boolean contains(int value) {
- boolean status = false;
- for (int i = 0; i < Array.length; i++) {
- if (Array[i] == value)
- System.out.println("true");
- status = true;
- }
- return status;
- }
- @Override
- public void Insert(int value) {
- if (Array.length >= capacity) {
- expandCapacity();
- }
- for (int i = 0; i < Array.length; i++) {
- if (Array[i] == value) {
- System.out.println("there is value like this");
- }
- }
- // what to put :D
- }
- public String toString() {
- String out = "";
- for (int i = 0; i < this.Array.length; i++)
- out += this.Array[i] + " ";
- return out;
- }
- @Override
- public int Find(int value) {
- int count = 0;
- int index = -1;
- do {
- if (this.Array[count] == value)
- index = count;
- count++;
- } while (index == -1 && count < Array.length);
- return index;
- }
- public static void main(String[] args) {
- Search testing = new Search();
- testing.Insert(2211, 1);
- testing.Insert(2211, 2);
- System.out.println(testing.toString());
- System.out.println(testing.Find(221));
- }
- }
Add Comment
Please, Sign In to add comment