Skip to content

Instantly share code, notes, and snippets.

@dested
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dested/fba9cdd2f66cd9b5460d to your computer and use it in GitHub Desktop.
Save dested/fba9cdd2f66cd9b5460d to your computer and use it in GitHub Desktop.
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