Advertisement
earlution

AggregatedClass.java

Oct 5th, 2021 (edited)
686
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.73 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4.  * Contains methods for which are called from the main object.
  5.  *
  6.  * @author (Ruari Mears)
  7.  * @version (05.10.2021)
  8.  */
  9. public class AggregatedClass
  10. {
  11.     private Scanner scanner;
  12.  
  13.     /**
  14.      * Constructor for objects of class TestClass
  15.      */
  16.     public AggregatedClass() {
  17.         scanner = new Scanner(System.in);
  18.     }
  19.  
  20.     public void standardOutput() {
  21.         System.out.println();
  22.         System.out.println("You wanted to see standard output.");
  23.     }
  24.    
  25.     public String standardInput() {
  26.         String userInput = captureInput();
  27.         return userInput;
  28.     }
  29.    
  30.     public void standardInputAndOutput() {
  31.         String userInput = captureInput();
  32.         outputUserInput(userInput);
  33.     }
  34.    
  35.     protected String captureInput() {
  36.         System.out.println();
  37.         System.out.println("Please input your first name: ");
  38.         String firstName = scanner.next();
  39.         System.out.println("And now your last name: ");
  40.         String lastName = scanner.next();
  41.         System.out.println("Type 'Computer Science is cool!' ");
  42.         String statement = scanner.next();
  43.         System.out.println();
  44.         String userInput = String.format(firstName + "%s" + lastName + "%s" + statement,
  45.             System.lineSeparator(),
  46.             System.lineSeparator());
  47.         return userInput;
  48.     }
  49.    
  50.     protected void outputUserInput(String userInput) {
  51.         System.out.println(userInput);
  52.     }
  53.    
  54.     public void method3() {
  55.         System.out.println();
  56.         System.out.println("Yay, you called method3()");
  57.     }
  58.  
  59.     public void method4() {
  60.         System.out.println();
  61.         System.out.println("Yay, you called method4()");
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement