Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Basic aggregation class structure using a menu-based approach.
- *
- * @author (Ruari Mears)
- * @version (05.01.2021)
- */
- public class BasicAggregationWithMenu
- {
- private AggregatedClass aggregatedObject = new AggregatedClass();
- public static void main(String[] args){
- BasicAggregationWithMenu main = new BasicAggregationWithMenu();
- main.menu();
- }
- private void menu(){
- Scanner scanner = new Scanner(System.in);
- System.out.println("1 Standard output");
- System.out.println("2 Standard input");
- System.out.println("3 Standard input and output");
- System.out.println("4 Menu item 4");
- System.out.println();
- System.out.println("Please enter your choice:");
- int choice = scanner.nextInt();
- switch (choice) {
- case 1:
- System.out.println("You chose to see standard output...");
- aggregatedObject.standardOutput();
- break;
- case 2:
- System.out.println("You chose to provide input to the " +
- "standard input stream...");
- aggregatedObject.standardInputAndOutput();
- break;
- case 3:
- System.out.println("You chose the 3rd menu item...");
- aggregatedObject.method3();
- break;
- case 4:
- System.out.println("You chose the 4th menu item...");
- aggregatedObject.method4();
- break;
- default: System.out.println("Invalid choice");
- }
- }
- }
Add Comment
Please, Sign In to add comment