This repository acts as a personal archive for my solutions to EdX course *Data Structures and Software Design* from PennX.
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.

53 lines
1.4 KiB

  1. /*
  2. * SD2x Homework #8
  3. * This class represents the Presentation Tier in the three-tier architecture.
  4. * Implement the appropriate methods for this tier below.
  5. * Also implement the start method as described in the assignment description.
  6. */
  7. import java.util.Scanner;
  8. import java.util.List;
  9. public class PresentationTier {
  10. private LogicTier logicTier; // link to the Logic Tier
  11. private final Scanner input;
  12. public PresentationTier(LogicTier logicTier) {
  13. this.input = new Scanner(System.in);
  14. this.logicTier = logicTier;
  15. }
  16. public void start() {
  17. String cmd = "";
  18. while(!cmd.equals("exit")){
  19. System.out.print(">>> ");
  20. cmd = input.nextLine();
  21. switch(cmd){
  22. case "author":
  23. showBookTitlesByAuthor();
  24. break;
  25. case "year":
  26. showNumberOfBooksInYear();
  27. break;
  28. default:
  29. System.out.println("Command not found!");
  30. }
  31. }
  32. }
  33. private void showBookTitlesByAuthor(){
  34. System.out.print("Author Name: ");
  35. String author = input.nextLine();
  36. List<String> titles = logicTier.findBookTitlesByAuthor(author);
  37. for(String t:titles)
  38. System.out.println("- " + t);
  39. }
  40. private void showNumberOfBooksInYear(){
  41. }
  42. }