ass_3.java
来自「真的很麻烦也」· Java 代码 · 共 68 行
JAVA
68 行
import java.io.FileWriter;
import java.io.*;
import java.io.FileNotFoundException;
public class ass_3
{
public static void main(String [] args)
{
LinkedStackTester newTester = new LinkedStackTester();
newTester.run();
}
}
class LinkedStackTester
{
private LinkedStack TestStack;
private PrintWriter copy;
public LinkedStackTester()
{
TestStack = new LinkedStack();
try
{
copy = new PrintWriter(new FileWriter("output.txt"));
}
catch (IOException err)
{
System.out.println("IOException..");
System.exit(1);
}
}
public void run()
{
output("push(5)",TestStack.push(new Integer(5))); ;
output("push(3)",TestStack.push(new Integer(3)));
output("pop()",TestStack.pop()) ; ;
output("push(7)",TestStack.push(new Integer(7)));
output("top()",TestStack.top());
output("pop()",TestStack.pop()) ;
output("pop()",TestStack.pop()) ;
output("pop()",TestStack.pop()) ;
output("isEmpty()",new Boolean(TestStack.isEmpty())) ;
output("push(9)",TestStack.push(new Integer(9)));
output("push(2)",TestStack.push(new Integer(2)));
output("push(6)",TestStack.push(new Integer(6)));
output("push(9)",TestStack.push(new Integer(9)));
output("size()",new Integer(TestStack.size()));
output("push(13)",TestStack.push(new Integer(13)));
output("push(15)",TestStack.push(new Integer(15)));
copy.close();
}
private void output(String Operation, Object outPut)
{
System.out.println("Operation: " + Operation);
System.out.println("Output: " + outPut.toString());
System.out.println("Stack (linked list) contents: " + TestStack.getContent());
System.out.println("");
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?