Skip to content

Instantly share code, notes, and snippets.

@Vaysman
Created December 16, 2010 18:49
Show Gist options
  • Save Vaysman/743788 to your computer and use it in GitHub Desktop.
Save Vaysman/743788 to your computer and use it in GitHub Desktop.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package TestFirst;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author User1
*/
public class SuperStack {
/*
* List<Integer> list убрать совсем. оставить только строку mass.
*
*/
private List<Integer> list = new ArrayList<Integer>();
private String mass = "";
private int leng = 0;
private int index = 0;
public boolean isEmpty() {
return index==0;
}
public void push(int i) throws StackFullException {
if (index >= 10) {
throw new StackFullException();
}
/*
* какой смысл в этой строчке?
*/
Integer j = i;
mass=mass+j.toString();
leng = j.toString().length();
list.add(index, leng);
index++;
}
public int pop() throws StackEmptyException{
if (isEmpty())
throw new StackEmptyException();
String st = mass.substring(mass.length()-list.get(index-1), mass.length());
mass = mass.substring(0, mass.length()-list.remove(index-1));
index--;
int b = Integer.parseInt(st);
return b;
}
}
@Vaysman
Copy link
Author

Vaysman commented Dec 16, 2010

надо переписать эту реализацию.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment