Wed Nov 04, 2009 11:37 am
/**
* @(#)Abbreviation.java
*
*
* @author
* @version 1.00 2009/11/2
*/
import java.util.*;
public class Abbreviation
{
private String abbrName;
private String[] fullNames = new String[10];
Scanner sc = new Scanner (System.in);
public Abbreviation()
{}
public Abbreviation(String abbrName, String fullName)
{
abbrName = abbrName;
fullNames[0] = fullName;
}
public Abbreviation(Abbreviation abbr)// copy Abbreviation data to abbrName
{
abbrName = abbr.getAbbrName();
fullNames[0] = abbr.getFullName(abbr.getNumFullNames());
}
public String getAbbrName()
{
return(abbrName);
}
public int getNumFullNames()
{
return(0);
}
public String getFullName(int index)
{
return fullNames[index];
}
public boolean matchByAbbrName(String abbrName)
{
if (abbrName.equals(this.abbrName))
return true;
return false;
}
public boolean matchByAbbrPrefix(String abbrPrefix)
{
if (abbrPrefix.startsWith(this.abbrName))
return true;
return false;
}
public void addFullName(String fullName)
{
}
public void print()
{
System.out.println("Abbreviation: [ "+abbrName+" ]");
for (int i=0; i<fullNames.length; i++)
System.out.println("[ "+fullNames[i]+" ]");
}
}
/**
* @(#)Database.java
*
*
* @author
* @version 1.00 2009/11/2
*/
import java.util.*;
import java.io.*;
public class Database
{
private Abbreviation[] abbreviations;
Abbreviation abbr;
public Database(String filename)
{
String str1, str2;
try
{
FileReader frStream = new FileReader("abbreviations.txt");
BufferedReader brStream = new BufferedReader(frStream);
for (int i=0; i<abbreviations.length; i++)
{
String inputLine = brStream.readLine();
}brStream.close();
}
catch (Exception e)
{
System.out.println("Error opening the input file!!!");
}
}
public int getNumAbbreviations()
{
for (int i=0; i<abbr.length; i++)
return i;
}
public Abbreviation getAbbreviationByIndex(int index)
{
return null;
}
public void printAllAbbreviations()
{
//System.out.println(inputLine);
}
public Abbreviation queryByAbbrName(String abbrName)
{
return null;
}
public Abbreviation[] queryByAbbrPrefix(String abbrPrefix)
{
return null;
}
}
/**
* @(#)MainApp.java
*
*
* @author
* @version 1.00 2009/11/2
*/
import java.util.*;
import java.lang.*;
import java.io.*;
public class MainApp
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader input= new BufferedReader(reader);
int choice;
String abbreviationsFile = "abbreviations.txt";
System.out.println("Reading data set from ["+abbreviationsFile+"]");
do{
System.out.println("\nWelcome to Abbreviation System");
System.out.println("==========================");
System.out.println("0. Display this menu");
System.out.println("1. List all abbreviations");
System.out.println("2. Query abbreviation by exact match");
System.out.println("3. Query abbreviation by prefix match");
System.out.println("4. File translation");
System.out.println("5. Abbreviation Quiz");
System.out.println("9. Exit");
System.out.print("Enter your choice: ");
choice=sc.nextInt();
switch(choice)
{
case 0:
break;
case 1: database.printAllAbbreviations();
break;
case 2:
break;
case 3:
break;
case 4:
break;
case 5:
break;
case 9: System.out.println("Program Terminating....");
break;
}
}while(choice!=9);
}
}
Wed Nov 04, 2009 2:05 pm
Wed Nov 04, 2009 4:15 pm
Wed Dec 26, 2012 7:45 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.