main
unknown
plain_text
3 years ago
3.2 kB
11
Indexable
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package s00015;
import java.util.Scanner;
/**
*
* @author MSI GTX
*/
public class S00015 {
private static Manager Manager;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
boolean valid = true;
do { //vòng lặp để không bị thoát khi có exception
try {
valid = true;
Manager = new Manager();
Manager.loadVocabulary();
Scanner cin = new Scanner(System.in); //Tạo đối tượng Scanner
int func; //được chọn bơi người dùng
do { //vòng lặp để hiển thị menu cho đên khi người dùng chọn số 4
System.out.println("====== Format CSV Program =======");
System.out.println("1. Add Word");
System.out.println("2. Delete Word");
System.out.println("3. Translate");
System.out.println("4. Exit");
System.out.print("Please choice one optine: ");
func = cin.nextInt();
cin.nextLine();
switch (func) {
case 1:
System.out.println("------------- Add Word ------------");
Manager.addWord(); //thêm từ mới bằng phương thức addWord
break;
case 2:
System.out.println("-------- Delete Word --------");
Manager.removeWord(); //xóa từ bằng phương thức removeWord
break;
case 3:
System.out.println("---------- Translate ----------");
Manager.translate(); //dịch từ bằng phương thức translate
break;
case 4:
System.out.println("================================");
System.out.println("Thank you for using our software!\n");
break;
default:
System.out.println("Error: The selection must be a integer number from 1 to 4!");
}
} while (func != 4); // Thoat vòng lặp khi chọn 4
} catch (Exception e) {
//Lỗi khi nhập sai kiểu dữ liệu
System.out.println("Error: The selection must be a number!");
valid = false;
}
} while (valid == false);
try {
Manager.saveVocabulary();
} catch (Exception e) {
System.out.println("Exception: Can't save vocabulary!");
}
}
}
Editor is loading...