prestige

Untitled

Dec 27th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. MyVector<Yacht> vec;
  2. vec = new MyVector<Yacht>();
  3. MyVector<SallingYacht> sv = new MyVector<>();
  4. averageCostOfYacht(sv);
  5. System.out.println("Если хотите выбрать ввод данных с клавиатуры нажмите 1, если сгенерировать случайно, то 2:");
  6. Scanner sc = new Scanner(System.in);
  7. int typeOfInterface = sc.nextInt();
  8. System.out.println("Если хотите загрузить сохраненые данные из файла нажмите 1, иначе 2:");
  9. int actionType = sc.nextInt();
  10. if (actionType == 1) {
  11. ObjectInputStream ins = null;
  12. try {
  13. ins = new ObjectInputStream(new FileInputStream("D:\\University\\5_course\\Java\\Container.dat"));
  14. Object tmp = ins.readObject();
  15. if (tmp.getClass() == vec.getClass())
  16. vec = (MyVector<Yacht>)tmp;
  17. } catch (FileNotFoundException e) {
  18. System.out.println(e);
  19. } finally {
  20. System.out.println("Sucessfully load.");
  21. ins.close();
  22. }
  23. }
  24. if (typeOfInterface == 1) {
  25. KeyboardDialog ob = new KeyboardDialog();
  26. while (true) {
  27. ob.inputInformation(typeOfInterface, vec);
  28. ob.inputFromKeyboard(vec);
  29. if (ob.actionType == 4)
  30. break;
  31. }
  32. } else if (typeOfInterface == 2) {
  33. RandomDialog ob = new RandomDialog();
  34. while (true) {
  35. ob.inputInformation(typeOfInterface, vec);
  36. ob.inputRandomData(vec);
  37. if (ob.actionType == 4)
  38. break;
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment