-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage1.java
More file actions
65 lines (60 loc) · 2.05 KB
/
Copy pathMessage1.java
File metadata and controls
65 lines (60 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* 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 message1;
import java.util.Scanner;
/**
*
* @author quoch
*/
public class Message1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner sca = new Scanner(System.in);
Scanner formessage = new Scanner(System.in);
Queue que = new Queue(1);
boolean end = false;
try{
while (end == false) {
System.out.println("1. Enter message");
System.out.println("2.Show all message");
System.out.println("3. Exit");
System.out.println("Enter your choice: ");
int choice = sca.nextInt();
switch (choice) {
case 1:
System.out.println("Enter a message");
String Message;
Message = formessage.nextLine();
if(Message.length() >=250){
System.out.println("the length limit of string is 250 . Please try again!");
}else{
System.out.println("Message has added to system");
que.enqueue(Message);
que.dequeue();
}
break;
case 2:
System.out.println("-------------");
System.out.println("All message");
System.out.println("");
que.displaystack();
System.out.println("--------------");
break;
case 3:
end = true;
break;
default:
break;
}
}
}catch(Exception e){
System.out.println("Error");
}
}
}