Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Pontus Eklund
- poek1067
- */
- import java.util.*;
- public class Main {
- private Scanner myScanner = new Scanner(System.in);
- public static void main(String[] args) {
- new Main().run();
- }
- private void run() {
- Event eventA = new Event("Marathon", 1);
- Participant participantA = new Participant("John", "Smith", "Ireland");
- Participant participantB = new Participant("John", "Johnson", "UK");
- Team team = new Team(participantA.getTeam());
- Team.teams.add(team);
- Event.events.add(eventA);
- Participant.participantList.add(participantA);
- Participant.participantList.add(participantB);
- boolean bool = true;
- while (bool) {
- System.out.println("Welcome! Please enter your command:");
- String answer = myScanner.nextLine();
- switch (answer) {
- case "add event":
- Event.addEvent(myScanner);
- break;
- case "add participant":
- Participant.addParticipant(myScanner);
- break;
- case "remove participant":
- Participant.removeParticipant(myScanner);
- break;
- case "add result":
- Result.addResult(myScanner);
- break;
- case "participant":
- Participant.participant(myScanner);
- break;
- case "exit":
- System.out.println("Terminating program");
- bool = false;
- break;
- default:
- if (answer.substring(0,7).equals("message")) {
- message(answer);
- break;
- }
- else if (Event.isEvent(answer)) {
- Event.eventStanding(answer);
- break;
- }
- else{
- System.out.println("Error. Please enter a correct command.");
- break;
- }
- }
- }
- }
- private void message(String answer) {
- String message = answer.substring(7).toUpperCase();
- int height = 5;
- int width = 60;
- int k = 0;
- char [][] matrix = new char[height][width];
- for (int i = 0; i < matrix.length; i++) {
- for (int j = 0; j < matrix[i].length; j++) {
- if (i == 0 || i == matrix.length - 1 || j == matrix[i].length - 1 || j == 0) {
- matrix[i][j] = '#';
- } else if (j == 1 || j == matrix[i].length - 2) {
- matrix[i][j] = ' ';
- } else if (i == Math.floor(matrix.length / 2) && j <= message.length() + 1) {
- matrix[i][j] = message.charAt(k);
- k++;
- } else {
- matrix[i][j] = ' ';
- }
- }
- }
- String temp;
- for (int i = 0; i < matrix.length; i++) {
- temp = new String(matrix[i]);
- System.out.println(temp);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement