fork download
  1. package topica.test;
  2.  
  3.  
  4. import java.util.ArrayList;
  5. import java.util.Scanner;
  6.  
  7.  
  8.  
  9. import topica.io.function;
  10. import topica.moduel.CanBo;
  11. import topica.moduel.ExceptionCharacter;
  12. import topica.moduel.ExceptionValue;
  13. import topica.moduel.GiangVien;
  14. import topica.moduel.NhanVien;
  15.  
  16. public class Main {
  17.  
  18.  
  19.  
  20.  
  21. static Scanner sc = new Scanner(System.in);
  22. static String pathName = "C:\\Users\\ta\\Desktop\\javaProgram\\NhanVien";
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29. public static void menu()
  30. {
  31. System.out.println("!---------------------------------------!");
  32. System.out.println("!1.Thêm nhân viên-----------------------!");
  33. System.out.println("!2.Hiển thị danh sách-------------------!");
  34. System.out.println("!3.Tìm kiếm theo ID---------------------!");
  35. System.out.println("!4.Sắp xếp danh sách theo 1:Tên , 2:Tuổi!");
  36. System.out.println("!5.Sửa khách hàng theo ID---------------!");
  37. System.out.println("!6.Xóa khách hàng theo ID---------------!");
  38. System.out.println("!7.Biến đổi sang map--------------------!");
  39. System.out.println("!7.Kết thúc chương trình----------------!");
  40. System.out.println("!---------------------------------------!");
  41. }
  42.  
  43. public static void menu00()
  44. {
  45. System.out.println("!------------------!");
  46. System.out.println("!1.Thêm giảng viên-!");
  47. System.out.println("!2.Thêm cán bộ-----!");
  48. System.out.println("!------------------!");
  49. boolean flag = true;
  50. do {
  51. int choice;
  52.  
  53. do {
  54. try {
  55. System.out.print("Nhập loại nhân viên của bạn : ");
  56. choice = Integer.parseInt(sc.nextLine());
  57. break;
  58.  
  59. } catch (Exception e) {
  60. // TODO: handle exception
  61. e.printStackTrace();
  62. }
  63.  
  64.  
  65.  
  66. } while (true);
  67.  
  68.  
  69.  
  70. switch (choice) {
  71. case 1:
  72. {
  73. themgiangvien();
  74. flag = false;
  75. break;
  76.  
  77. }
  78.  
  79. case 2:
  80. {
  81. themcanbo();
  82. flag = false;
  83. break;
  84.  
  85. }
  86.  
  87.  
  88.  
  89. default:
  90. {
  91. System.out.println("Nhập sai vui lòng nhập lại !");
  92. }
  93. }
  94.  
  95.  
  96. } while (flag);
  97.  
  98.  
  99. }
  100.  
  101.  
  102. private static void themcanbo() {
  103. // TODO Auto-generated method stub
  104.  
  105. System.out.println("!-------------Nhập thông tin cán bộ-------------!");
  106. GiangVien nv = new GiangVien();
  107. do {
  108. try {
  109. nv.inputID();
  110. break;
  111. } catch (ExceptionCharacter e) {
  112. // TODO Auto-generated catch block
  113. e.printStackTrace();
  114. }
  115.  
  116. } while (true);
  117.  
  118. nv.inputName();
  119.  
  120. do {
  121. try {
  122.  
  123. nv.inputAge();
  124. break;
  125. } catch (ExceptionValue e) {
  126. // TODO Auto-generated catch block
  127. e.printStackTrace();
  128. }
  129.  
  130. } while (true);
  131.  
  132. nv.inputInformation();
  133.  
  134. System.out.println("!------------------Kết thúc nhập-----------------!");
  135.  
  136. boolean flag = function.addnhanvien(nv, pathName);
  137. if(flag)
  138. {
  139. System.out.println("Ghi thành công !");
  140. }
  141. else
  142. {
  143. System.out.println("Lỗi !");
  144. }
  145.  
  146.  
  147. }
  148.  
  149.  
  150. private static void themgiangvien() {
  151. // TODO Auto-generated method stub
  152.  
  153. System.out.println("!-------------Nhập thông tin giảng viên------------!");
  154. CanBo nv = new CanBo();
  155. do {
  156. try {
  157. nv.inputID();
  158. break;
  159. } catch (ExceptionCharacter e) {
  160. // TODO Auto-generated catch block
  161. e.printStackTrace();
  162. }
  163.  
  164. } while (true);
  165.  
  166.  
  167. nv.inputName();
  168.  
  169. do {
  170. try {
  171. nv.inputAge();
  172. break;
  173. } catch (Exception e) {
  174. // TODO: handle exception
  175. e.printStackTrace();
  176. }
  177.  
  178.  
  179.  
  180.  
  181. } while (true);
  182.  
  183. nv.inputInformation();
  184.  
  185. System.out.println("!------------------Kết thúc nhập-----------------!");
  186.  
  187.  
  188. boolean flag = function.addnhanvien(nv, pathName);
  189. if(flag)
  190. {
  191. System.out.println("Ghi thành công !");
  192. }
  193. else
  194. {
  195. System.out.println("Ghi thất bại !");
  196. }
  197.  
  198.  
  199. }
  200.  
  201.  
  202.  
  203.  
  204.  
  205. public static void main(String[] args) {
  206. // TODO Auto-generated method stub
  207. menu();
  208.  
  209. boolean flag = true;
  210.  
  211.  
  212. do {
  213.  
  214. int choice;
  215. do {
  216.  
  217.  
  218. try {
  219.  
  220. System.out.print("Nhập lựa chọn của bạn : ");
  221. choice = Integer.parseInt(sc.nextLine());
  222. break;
  223.  
  224.  
  225. } catch (Exception e) {
  226. // TODO: handle exception
  227. e.printStackTrace();
  228. }
  229.  
  230.  
  231.  
  232.  
  233.  
  234. } while (true);
  235. switch (choice) {
  236. case 1:
  237. {
  238.  
  239. menu00();
  240. break;
  241. }
  242.  
  243. case 2 :
  244. {
  245. DisplayList();
  246. break;
  247. }
  248.  
  249. case 3 :
  250. {
  251. find();
  252. break;
  253. }
  254.  
  255. case 4 :
  256. {
  257. sapxep();
  258. break;
  259. }
  260. case 5 :
  261. {
  262. suathongtin();
  263. break;
  264. }
  265.  
  266. case 6 :
  267. {
  268. xoathongtin();
  269. break;
  270. }
  271.  
  272.  
  273. case 7 :
  274. {
  275. System.out.println("Kết thúc chương trình !");
  276. flag = false;
  277. break;
  278. }
  279.  
  280.  
  281.  
  282. default:
  283. {
  284. System.out.println("Nhập sai vui lòng nhập lại !");
  285.  
  286. }
  287.  
  288.  
  289. }
  290.  
  291.  
  292. } while (flag);
  293.  
  294. }
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301. private static void xoathongtin() {
  302. // TODO Auto-generated method stub
  303. ArrayList<NhanVien> arr = function.docFile(pathName);
  304. System.out.print("Nhập ID cần xóa : ");
  305. String s = sc.nextLine();
  306. if(function.findID(s, pathName)!=-1)
  307. {
  308. arr.remove(function.findID(s, pathName));
  309. function.luuFile(arr, pathName);
  310. }
  311. else
  312. {
  313. System.out.println("Không tìm thấy ID");
  314. }
  315.  
  316.  
  317.  
  318. }
  319.  
  320. private static void suathongtin() {
  321. // TODO Auto-generated method stub
  322. ArrayList<NhanVien> arr = function.docFile(pathName);
  323. System.out.print("Nhập mã nhân viên cần thay đổi : ");
  324. String s = sc.nextLine();
  325. int vt = function.findID(s, pathName);
  326. if(vt!=-1)
  327. {
  328. System.out.println("!------------!");
  329. System.out.println("!1.Cán bộ----!");
  330. System.out.println("!2.Giảng viên!");
  331. System.out.println("!------------!");
  332. System.out.print("Nhập lựa chọn của bạn : ");
  333. int choice = Integer.parseInt(sc.nextLine());
  334.  
  335.  
  336. switch (choice) {
  337. case 1:
  338. {
  339. GiangVien gv = new GiangVien();
  340.  
  341.  
  342.  
  343. do {
  344.  
  345. try {
  346. gv.inputID();
  347. break;
  348.  
  349. } catch (ExceptionCharacter e) {
  350. // TODO Auto-generated catch block
  351. e.printStackTrace();
  352. }
  353. } while (true);
  354.  
  355.  
  356.  
  357. gv.inputName();
  358.  
  359.  
  360.  
  361.  
  362. do {
  363. try {
  364. gv.inputAge();
  365. break;
  366.  
  367. } catch (ExceptionValue e) {
  368. // TODO Auto-generated catch block
  369. e.printStackTrace();
  370. }
  371.  
  372. } while (true);
  373.  
  374.  
  375. gv.inputInformation();
  376.  
  377.  
  378.  
  379. arr.set(vt, gv);
  380. function.luuFile(arr, pathName);
  381.  
  382. break;
  383.  
  384. }
  385.  
  386. case 2:
  387. {
  388. CanBo cb = new CanBo();
  389.  
  390.  
  391. do {
  392. try {
  393. cb.inputID();
  394. break;
  395. } catch (ExceptionCharacter e) {
  396. // TODO Auto-generated catch block
  397. e.printStackTrace();
  398. }
  399.  
  400. } while (true);
  401.  
  402. cb.inputName();
  403.  
  404. do {
  405.  
  406. try {
  407. cb.inputAge();
  408. break;
  409. } catch (ExceptionValue e) {
  410. // TODO Auto-generated catch block
  411. e.printStackTrace();
  412. }
  413.  
  414. } while (true);
  415.  
  416. cb.inputInformation();
  417.  
  418.  
  419.  
  420. arr.set(vt, cb);
  421. function.luuFile(arr, pathName);
  422. break;
  423.  
  424. }
  425.  
  426. default:
  427. break;
  428. }
  429.  
  430.  
  431.  
  432. }
  433.  
  434. else
  435. {
  436. System.out.println("Không tìm thấy mã !");
  437. }
  438.  
  439. }
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446. private static void sapxep() {
  447. // TODO Auto-generated method stub
  448. function.comparato(pathName);
  449.  
  450.  
  451.  
  452. }
  453.  
  454.  
  455.  
  456. private static void find() {
  457. // TODO Auto-generated method stub
  458. System.out.print("Nhập vào ID cần tìm : ");
  459. String str = sc.nextLine();
  460. NhanVien nv = function.find(str, pathName);
  461. if(nv==null)
  462. {
  463. System.out.println("Không tìm thấy ID");
  464.  
  465. }
  466. else
  467. {
  468. System.out.println(nv.toString());
  469. }
  470. }
  471.  
  472.  
  473.  
  474.  
  475. private static void DisplayList() {
  476. // TODO Auto-generated method stub
  477. ArrayList<NhanVien> arr = function.docFile(pathName);
  478. for (NhanVien nhanVien : arr) {
  479. System.out.println(nhanVien.toString());
  480. }
  481.  
  482.  
  483.  
  484.  
  485. }
  486.  
  487. }
  488.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:9: error: package topica.io does not exist
import topica.io.function;
                ^
Main.java:10: error: package topica.moduel does not exist
import topica.moduel.CanBo;
                    ^
Main.java:11: error: package topica.moduel does not exist
import topica.moduel.ExceptionCharacter;
                    ^
Main.java:12: error: package topica.moduel does not exist
import topica.moduel.ExceptionValue;
                    ^
Main.java:13: error: package topica.moduel does not exist
import topica.moduel.GiangVien;
                    ^
Main.java:14: error: package topica.moduel does not exist
import topica.moduel.NhanVien;
                    ^
Main.java:106: error: cannot find symbol
		GiangVien nv = new GiangVien();
		^
  symbol:   class GiangVien
  location: class Main
Main.java:106: error: cannot find symbol
		GiangVien nv = new GiangVien();
		                   ^
  symbol:   class GiangVien
  location: class Main
Main.java:111: error: cannot find symbol
			} catch (ExceptionCharacter e) {
			         ^
  symbol:   class ExceptionCharacter
  location: class Main
Main.java:125: error: cannot find symbol
			} catch (ExceptionValue e) {
			         ^
  symbol:   class ExceptionValue
  location: class Main
Main.java:136: error: cannot find symbol
		boolean flag = function.addnhanvien(nv, pathName);
		               ^
  symbol:   variable function
  location: class Main
Main.java:154: error: cannot find symbol
		CanBo nv = new CanBo();
		^
  symbol:   class CanBo
  location: class Main
Main.java:154: error: cannot find symbol
		CanBo nv = new CanBo();
		               ^
  symbol:   class CanBo
  location: class Main
Main.java:159: error: cannot find symbol
			} catch (ExceptionCharacter e) {
			         ^
  symbol:   class ExceptionCharacter
  location: class Main
Main.java:188: error: cannot find symbol
		boolean flag = function.addnhanvien(nv, pathName);
		               ^
  symbol:   variable function
  location: class Main
Main.java:303: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		          ^
  symbol:   class NhanVien
  location: class Main
Main.java:303: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		                          ^
  symbol:   variable function
  location: class Main
Main.java:306: error: cannot find symbol
		if(function.findID(s, pathName)!=-1)
		   ^
  symbol:   variable function
  location: class Main
Main.java:308: error: cannot find symbol
			arr.remove(function.findID(s, pathName));
			           ^
  symbol:   variable function
  location: class Main
Main.java:309: error: cannot find symbol
			function.luuFile(arr, pathName);
			^
  symbol:   variable function
  location: class Main
Main.java:322: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		          ^
  symbol:   class NhanVien
  location: class Main
Main.java:322: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		                          ^
  symbol:   variable function
  location: class Main
Main.java:325: error: cannot find symbol
		int vt = function.findID(s, pathName);
		         ^
  symbol:   variable function
  location: class Main
Main.java:339: error: cannot find symbol
				GiangVien gv = new GiangVien();
				^
  symbol:   class GiangVien
  location: class Main
Main.java:339: error: cannot find symbol
				GiangVien gv = new GiangVien();
				                   ^
  symbol:   class GiangVien
  location: class Main
Main.java:349: error: cannot find symbol
					} catch (ExceptionCharacter e) {
					         ^
  symbol:   class ExceptionCharacter
  location: class Main
Main.java:367: error: cannot find symbol
					} catch (ExceptionValue e) {
					         ^
  symbol:   class ExceptionValue
  location: class Main
Main.java:380: error: cannot find symbol
				function.luuFile(arr, pathName);
				^
  symbol:   variable function
  location: class Main
Main.java:388: error: cannot find symbol
				CanBo cb = new CanBo();
				^
  symbol:   class CanBo
  location: class Main
Main.java:388: error: cannot find symbol
				CanBo cb = new CanBo();
				               ^
  symbol:   class CanBo
  location: class Main
Main.java:395: error: cannot find symbol
					} catch (ExceptionCharacter e) {
					         ^
  symbol:   class ExceptionCharacter
  location: class Main
Main.java:409: error: cannot find symbol
					} catch (ExceptionValue e) {
					         ^
  symbol:   class ExceptionValue
  location: class Main
Main.java:421: error: cannot find symbol
				function.luuFile(arr, pathName);
				^
  symbol:   variable function
  location: class Main
Main.java:448: error: cannot find symbol
		function.comparato(pathName);
		^
  symbol:   variable function
  location: class Main
Main.java:460: error: cannot find symbol
		  NhanVien nv = function.find(str, pathName);
		  ^
  symbol:   class NhanVien
  location: class Main
Main.java:460: error: cannot find symbol
		  NhanVien nv = function.find(str, pathName);
		                ^
  symbol:   variable function
  location: class Main
Main.java:477: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		          ^
  symbol:   class NhanVien
  location: class Main
Main.java:477: error: cannot find symbol
		ArrayList<NhanVien> arr = function.docFile(pathName);
		                          ^
  symbol:   variable function
  location: class Main
Main.java:478: error: cannot find symbol
		for (NhanVien nhanVien : arr) {
		     ^
  symbol:   class NhanVien
  location: class Main
39 errors
stdout
Standard output is empty