Last active
August 29, 2015 14:24
-
-
Save dested/fba9cdd2f66cd9b5460d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
public class NameApp { | |
private String name; | |
private int[] popularityRanks; | |
public static void main (String[] args) throws FileNotFoundException { | |
Name[] names = new Name[4429]; | |
makeObjects(names); | |
output(names); | |
} | |
public static void makeObjects(Name[] names) throws FileNotFoundException { | |
Scanner input = new Scanner(new File("names.txt")); | |
String temp; | |
int i = 0; | |
while (input.hasNextLine()) { | |
temp = input.nextLine(); | |
names[i] = new Name(); | |
names[i].setName(temp); | |
i = i + 1; | |
} | |
Name selectedName = getName("Dicks"); | |
if(selectedName==null){ | |
System.out.println("Name not found"); | |
}else{ | |
System.out.println("Name found"); | |
} | |
} | |
public static Name getName(string name){ | |
//search code | |
for(int index=0; index<names.length,index++){ | |
if(names[index].getName()==name){ | |
return names[index]; | |
} | |
} | |
return null; | |
} | |
public static void output(Name[] names) { | |
for (int i = 0; i < 4429; i++) { | |
System.out.println(names[i].getName()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment