Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. import java.util.ArrayList;
  2.  
  3. /**
  4. * Created by PAS43 on 02/02/2016.
  5. *
  6. * VList
  7. */
  8. public class Main {
  9. public static void main(String[] args) {
  10. VList v = new VList();
  11.  
  12. v.add(10);
  13. v.add(20);
  14. v.add(30);
  15. v.add(40);
  16. v.add(50);
  17. v.add(60);
  18. v.add(70);
  19. v.add(80);
  20. v.add(90);
  21. v.add(100);
  22. }
  23. }
  24.  
  25. class VList{
  26.  
  27. private ArrayList<VList> referenceToLists = new ArrayList<>();
  28. private Number values = new Number();
  29. private int currentValue = 0;
  30. private static int amountOfLists = 0;
  31. private final static int maxValue = 5;
  32.  
  33. VList(){
  34. referenceToLists.add(this);
  35. }
  36.  
  37. public void add(Integer i){
  38. if(referenceToLists.get(amountOfLists).getCurrentValue() < maxValue) {
  39. referenceToLists.get(amountOfLists).values.add(i);
  40. currentValue++;
  41. } else {
  42. amountOfLists++;
  43. currentValue = 0;
  44. referenceToLists.add(amountOfLists, new VList());
  45. referenceToLists.get(amountOfLists).values.add(i);
  46.  
  47. }
  48. }
  49. public int getCurrentValue() {
  50. return currentValue;
  51. }
  52. }
  53.  
  54. class Number{
  55. Integer[] values = new Integer[5];
  56. int currentIndex = 0;
  57.  
  58. public void add(Integer input){
  59. if(currentIndex < 5) {
  60. values[currentIndex] = input;
  61. currentIndex++;
  62. } else {
  63. System.out.println("Number Index Over 4");
  64. }
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement