this is a program to let me open a file and read birthday and related name, and then type name we can fetch the birthday, everything is ok ,whenever i input a name, it always find nothing, can some experts help me please
there are three class i defined, one is birth_reader, another is date to record the date have been read from specified file, one is the name stored firstname and last name, the file my lecture give me is just a simple txt file which is example like:
1 31 1984 robin ralu
.........................
please
import java.util.Scanner.*;
import java.util.*;
import java.io.*;
public class birth_reader
{
public static void main(String[] args)throws IOException
{
birth_reader haha=new birth_reader();
Map <name,date> book=new HashMap<name,date>();
Scanner input=new Scanner(System.in);
name b;
FileReader fin = new FileReader("birthday.txt");
Scanner sc = new Scanner(fin);
while(sc.hasNext())
{
int cat=sc.nextInt();
int cta=sc.nextInt();
int atc=sc.nextInt();
String first_name=sc.next();
String last_name=sc.next();
date a=new date(cat,cta,atc);
b=new name(first_name,last_name);
book.put(b,a);
System.out.println(book);
}
System.out.println("please enter the name");
String f=input.next();
String l=input.next();
b.firstname=f;
b.lastname=l;
date p=book.get(b);
if((p!=null))
{
System.out.println(b+":"+p);
}
else{ System.out.println("no person here"+" "+b);
}
}
}
public class name
{
String firstname,lastname;
public name(String firstname,String lastname)
{
this.firstname=firstname;
this.lastname=lastname;
}
public String toString()
{
return firstname+" "+lastname;
}
}
public class date
{
int year,month,day;
public date(int year,int month,int day)
{
this.year=year;
this.month=month;
this.day=day;
}
public String toString()
{
return year+" "+month+" "+day;
}
public int getyear()
{
return year;
}
public int getmonth()
{
return month;
}
public int getday()
{
return day;
}
}


