You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.6 KiB

  1. import java.io.IOException;
  2. import java.io.InputStream;
  3. import java.io.OutputStream;
  4. import java.nio.charset.StandardCharsets;
  5. import java.util.Scanner;
  6. public class PasswordManager implements PasswordManagerInterface {
  7. boolean running = true;
  8. InputStream inputStream = System.in;
  9. OutputStream outputStream = System.out;
  10. public static void main(String[] args) {
  11. PasswordManager pm = new PasswordManager();
  12. while (pm.running) {
  13. pm.showMenu(null, null);
  14. }
  15. System.exit(0);
  16. }
  17. public PasswordManager() {
  18. try {
  19. outputStream.write("Hello World\n".getBytes(StandardCharsets.UTF_8));
  20. } catch (IOException e) {
  21. e.printStackTrace();
  22. }
  23. }
  24. @Override
  25. public void listVaults() {
  26. }
  27. @Override
  28. public void openVault() {
  29. }
  30. @Override
  31. public void showMenu(InputStream inputStream, OutputStream outputStream) {
  32. if (inputStream == null) {
  33. inputStream = this.inputStream;
  34. }
  35. if (outputStream == null) {
  36. outputStream = this.outputStream;
  37. }
  38. StringBuilder sb = new StringBuilder();
  39. Scanner scan = new Scanner(inputStream);
  40. running = true;
  41. sb.append("ciip Gruppe 8 - Password Manager\n\n");
  42. sb.append("Menu:\n");
  43. sb.append("- exit: e\n");
  44. try {
  45. outputStream.write((sb + "\n").getBytes(StandardCharsets.UTF_8));
  46. } catch (IOException e) {
  47. e.printStackTrace();
  48. }
  49. String input = scan.nextLine();
  50. if (input.equals("e")) {
  51. running = false;
  52. }
  53. }
  54. }