importjava.io.FileReader;importjava.io.IOException;importjava.util.Iterator;importjava.util.Scanner;importjava.util.Vector;public classMain {//static Vector list ;//static Sets set;//private static Scanner scan;//private static Scanner scanstr;
public static void main(String[] args) throwsIOException{
Scanner scanstr;
Sets set= null;
Vector list = new Vector();
System.out.println("choose the way to initualize keyboard(1) or file(2),1 or 2:");
Scanner scans= newScanner(System.in);int i =scans.nextInt();if(i == 1){
System.out.println("type \" \" to quit");while(scans.hasNextLine()){
String str=scans.nextLine();if(str.equals(" ")){break;
}if(list.contains(str)) continue;elselist.add(str);
}
set= newMyString(list);
}if(i == 2){
list=FileInput();
set= newMyString(list);
}
System.out.println("choose how to operate Strings");
System.out.println("getOrder(1),findString(2),findSet(3)");
System.out.println("interset(4),times(5),add(6),delete(7),print(8)");while(scans.hasNextInt()){
scanstr= newScanner(System.in);
i=scans.nextInt();switch(i){case 1:
set.getOrder();
set.myTostring();break;case 2:booleanbool1;
System.out.println("type the string to find");
String strtemp=scanstr.nextLine();
bool1=set.findString(strtemp);if(bool1){
System.out.println("find"+strtemp+"in strings");
}else{
System.out.println("404!");
}break;case 3:booleanbool2;
Vector list1 = new Vector();
System.out.println("type the strings set to find");
System.out.println("type \" \" to quit");while(scanstr.hasNextLine()){
String str2=scanstr.nextLine();if(str2.equals(" ")){break;
}if(list1.contains(str2)) continue;elselist1.add(str2);
}
bool2=set.findSet(list1);if(bool2){
System.out.println("find set in strings");
}else{
System.out.println("404!");
}break;case 4:
Vector list2 = new Vector();
System.out.println("type the strings set to find");
System.out.println("type \" \" to quit");while(scanstr.hasNextLine()){
String str=scanstr.nextLine();if(str.equals(" ")){break;
}if(list2.contains(str)) continue;elselist2.add(str);
}
list2=set.interset(list2);
Iterator iter =list2.iterator();while(iter.hasNext()){
String strs=iter.next();
System.out.println(strs);
}break;case 5:
System.out.println("type the times to caculate");
String strtemp1=scanstr.nextLine();int j = 0;
j=set.times(strtemp1);
System.out.println(strtemp1+" "+j);break;case 6:
System.out.println("type the string to add");
String strtemp2=scanstr.nextLine();
set.add(strtemp2);
set.myTostring();break;case 7:
System.out.println("type the string to delete");
String strtemp3=scanstr.nextLine();
set.delete(strtemp3);
set.myTostring();break;
}
}
scans.close();
}public static Vector FileInput() throwsIOException{
FileReader reader= new FileReader("in.txt");inttemp;
Vectorlist;
list=new Vector();
StringBuffer b= newStringBuffer();while((temp = reader.read()) != -1){if((char)temp == '\r'){
String s=b.toString();
b.delete(0, b.length());if(list.contains(s)){continue;
}else{
list.add(s);continue;
}
}else if((char)temp == '\n'){continue;
}else{
b.append((char)temp);
}
}
reader.close();returnlist;
}
}