Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Contains methods for which are called from the main object.
- *
- * @author (Ruari Mears)
- * @version (05.10.2021)
- */
- public class AggregatedClass
- {
- private Scanner scanner;
- /**
- * Constructor for objects of class TestClass
- */
- public AggregatedClass() {
- scanner = new Scanner(System.in);
- }
- public void standardOutput() {
- System.out.println();
- System.out.println("You wanted to see standard output.");
- }
- public String standardInput() {
- String userInput = captureInput();
- return userInput;
- }
- public void standardInputAndOutput() {
- String userInput = captureInput();
- outputUserInput(userInput);
- }
- protected String captureInput() {
- System.out.println();
- System.out.println("Please input your first name: ");
- String firstName = scanner.next();
- System.out.println("And now your last name: ");
- String lastName = scanner.next();
- System.out.println("Type 'Computer Science is cool!' ");
- String statement = scanner.next();
- System.out.println();
- String userInput = String.format(firstName + "%s" + lastName + "%s" + statement,
- System.lineSeparator(),
- System.lineSeparator());
- return userInput;
- }
- protected void outputUserInput(String userInput) {
- System.out.println(userInput);
- }
- public void method3() {
- System.out.println();
- System.out.println("Yay, you called method3()");
- }
- public void method4() {
- System.out.println();
- System.out.println("Yay, you called method4()");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement