Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sem3task4;
- import java.util.ArrayList;
- import java.util.Scanner;
- /**
- *
- * @author Albin
- */
- public class Sem3Task4 {
- public int i = 0;
- public PhoneQueue [] queue = new PhoneQueue[10];
- Scanner scan = new Scanner(System.in);
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Sem3Task4 call = new Sem3Task4();
- Scanner scan = new Scanner(System.in);
- int menunr;
- while (true) {
- System.out.println("Menu");
- System.out.println("________________________");
- System.out.println("1. Add Queue");
- System.out.println("2. Answer Queue");
- System.out.println("3. Exit System");
- System.out.println("________________________");
- menunr = scan.nextInt();
- if (menunr == 1){
- call.addQueue();
- }
- else if (menunr == 2){
- call.rmQueue();
- }
- else if (menunr == 3){
- System.exit(0);
- }
- else {
- System.out.println("Need to be a number between 1-3");
- }
- }
- }
- public void addQueue(){
- if (i == 10) {
- System.out.println("Too many calls in queue");
- }
- else {
- System.out.println("Print the name of the caller");
- String callname = scan.nextLine();
- System.out.println("Print the number of the caller");
- String callphonenr = scan.nextLine();
- System.out.println();
- queue[i] = new PhoneQueue();
- queue[i].setName(callname);
- queue[i].setPhonenr(callphonenr);
- System.out.println();
- System.out.println("Call Added to Queue");
- System.out.println(queue[i].getName() + " " + queue[i].getPhonenr());
- i++;
- }
- }
- public void rmQueue(){
- if (i > 0) {
- i--;
- }
- System.out.println();
- System.out.println();
- int j = 9;
- for(int z = 0; z <= 8; z++) {
- System.out.println();
- System.out.println("Moving " + queue[z].getName()+ "-> " + queue[z+1].getName());
- queue[z] = queue[z+1];
- System.out.println(queue[z].getName());
- System.out.println();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement