-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
40 lines (33 loc) · 1021 Bytes
/
Copy pathMain.java
File metadata and controls
40 lines (33 loc) · 1021 Bytes
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
import java.sql.SQLOutput;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Run1();
}
public static void Run1(){
TStack<String> bookStack = new TStack<>();
try{
loadData(bookStack,7);
}catch(Exception e){
System.out.println("Exception "+e.getMessage());
e.printStackTrace();
return;
}
System.out.println("Book list from the last: ");
while(!bookStack.isEmpty()){
System.out.println(bookStack.pop());
}
}
public static void loadData(TStack<String> stack,int n){
if(stack==null){
throw new NullPointerException();
}
Scanner sc = new Scanner(System.in);
String tmp;
for(int i=0;i<=n;i++){
System.out.println(String.format("Insert %d/%d book: ",i,n));
tmp = sc.nextLine();
stack.push(tmp);
}
}
}