Guest User

Untitled

a guest
Jul 20th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.85 KB | None | 0 0
  1. import java.io.*;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Vector;
  5. import java.util.Collections;
  6.  
  7. public class assignment9
  8. {
  9. public static Vector<String> entire_cast = new Vector<String>();
  10. public static String[] preset_cast = {"Hugh Laurie as Greg House" ,
  11. "Robert Sean Leonard as Jamies Wilson",
  12. "Lisa Edelstein as Lisa Cuddy",
  13. "Omar Epps as Eric Foreman",
  14. "Jennifer Morrison as Allison Cameron",
  15. "Jesse Spencer as Robert Chase", "Ovivia Wilde as Dr. Hadley aka Thirteen",
  16. "Kal Penn as Lawrence Kutner",
  17. "Anne Dudek as Amber Volakis",
  18. "Sela Ward as Stacy Warner",
  19. "Peter Jacobson as Chris Taub"
  20. };
  21.  
  22. public void create_default_cast()
  23. {
  24. //header
  25. System.out.println();
  26. System.out.println();
  27. System.out.println("________________________________________");
  28. System.out.println("**** Cast of House MD ****");
  29. System.out.println("________________________________________");
  30. System.out.println();
  31. System.out.println();
  32.  
  33. //end header
  34.  
  35. for(String addcast : preset_cast)
  36. {
  37. entire_cast.add(addcast);
  38. }
  39. }
  40. public void print_cast()
  41. {
  42. Collections.sort(entire_cast);
  43. for(String cast:entire_cast)
  44. {
  45. System.out.println(cast);
  46. }
  47. }
  48. public void add_cast_member(String RealName, String StageName)
  49. {
  50. String Combine = RealName + " as " + StageName;
  51. entire_cast.add(Combine);
  52. System.out.println();
  53. System.out.println();
  54. print_cast();
  55. addAnother();
  56. }
  57. public void getName()
  58. {
  59. try
  60. {
  61. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  62. System.out.println();
  63. System.out.println("Ready to join the cast? Whats your name?");
  64. String getRealName = reader.readLine();
  65.  
  66. System.out.println();
  67. System.out.println("Great! What will be your characters name?");
  68. String getStageName = reader.readLine();
  69.  
  70. add_cast_member(getRealName, getStageName);
  71. reader.close();
  72. }
  73. catch (IOException e)
  74. {
  75. e.printStackTrace();
  76. }
  77. }
  78. public void addAnother()
  79. {
  80. try
  81. {
  82. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  83. System.out.println();
  84. System.out.println("Would you like to add another? ('yes' to continue adding)");
  85. String toContinue = reader.readLine();
  86. String sendtrue = "yes";
  87. if(toContinue.compareTo(sendtrue) >= 0)
  88. {
  89. getName();
  90. }
  91. else
  92. {
  93. System.out.println("Bye!");
  94. }
  95. reader.close();
  96. }
  97. catch (IOException e)
  98. {
  99. e.printStackTrace();
  100. }
  101. }
  102. public static void main(String[] args)
  103. {
  104.  
  105. assignment9 initialize = new assignment9();
  106. initialize.create_default_cast();
  107. initialize.print_cast();
  108. initialize.getName();
  109.  
  110. }
  111. }
Add Comment
Please, Sign In to add comment