Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //These are the 3 main classes needed to get this thing up and running
- //Main class
- import java.util.*;
- import java.awt.*;
- /**
- * Write a description of class Main here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Main
- {
- //
- public static void main(String args[])
- {
- MainList M = new MainList();
- //char t;
- //t = (char)145;
- //System.out.println(t);
- M.getList().add(new Sprite1());//1
- M.getList().add(new Sprite1());//1
- M.getList().add(new Sprite1());//1
- for(int F1 = 0; F1 < 2; F1++)
- {
- Sprite1 G = new Sprite1();//1
- for(int F = 0; F < 10; F++){
- G.getList().add(new Sprite1());//2
- }
- M.getList().add(G);
- for(int F3 = 0; F3 < 10; F3++)
- {
- Sprite1 V = (Sprite1)G.getList().get(F3);
- V.getList().add(new Sprite1());//3
- }
- }
- for(int F = 0; F < 6; F++)
- {
- System.out.println("\t\t\t\t\t" + "Cycle: ".toUpperCase() + F);
- M.allListUpdate();
- if(F == 1)
- {
- System.out.println("\t\t\t\t\t" + "Searching Lists ".toUpperCase());
- searchSubLists(M.getList(), "0");
- }
- if(F == 2)
- {
- System.out.println("\t\t\t\t\t" + "Adding To Lists ".toUpperCase());
- //addToSubLists(M.getList(), "5");
- addToSubLists(M.getList(), "2");
- }
- if(F == 3)
- {
- System.out.println("Main List Cleared!!!!!!!!!".toUpperCase());
- M.getList().clear();
- }
- }
- }
- public static void searchSubLists(LinkedList Sub, String Name)
- {
- //
- for(int fall = 0; fall < Sub.size(); fall++)
- {
- Sprite1 S1 = (Sprite1)Sub.get(fall);
- //System.out.print("List Depth: " + depths + " ");
- //System.out.print("Sprite : " + fall + "\t");
- if(S1.getName().contains(Name))
- {
- Sub.remove(fall);
- System.out.println("\t\tSprite ".toUpperCase() + fall + " Name : ".toUpperCase() + S1.getName().toUpperCase() + " Cleared!!!!!!!!! O".toUpperCase());
- }
- if(S1.HSL())
- {
- System.out.println("\t\tSprite1 : " + fall + "\n\t\t\tHas Sub List!" + "\n\t\t\t\tSearching List of " + S1.getName().toUpperCase() + " Now!");
- searchSubLists(S1.getList(), Name);
- }
- }
- }
- public static void addToSubLists(LinkedList Sub, String Name)
- {
- //
- for(int fall = 0; fall < Sub.size(); fall++)
- {
- Sprite1 S1 = (Sprite1)Sub.get(fall);
- //System.out.print("List Depth: " + depths + " ");
- //System.out.print("Sprite : " + fall + "\t");
- if(S1.getName().contains(Name))
- {
- System.out.println("\\ \\ \\ \\ \\ " + S1.getName().toUpperCase() + " New Sprite(s)!!!!!!!!!".toUpperCase());
- for(int G = 0; G < 2; G++)
- {
- Sub.add(new Sprite1());
- }
- System.out.println("\t\tSprite ".toUpperCase() + fall + " Name : ".toUpperCase() + S1.getName().toUpperCase() + " New Sprite(s)!!!!!!!!!".toUpperCase());
- }
- if(S1.HSL())
- {
- System.out.println("\t\tSprite1 : " + fall + "\n\t\t\tHas Sub List!" + "\n\t\t\t\tSearching List of " + S1.getName().toUpperCase() + " Now!");
- addToSubLists(S1.getList(), Name);
- }
- }
- }
- }
- //Main Class
- //Main List Manager
- import java.util.*;
- import java.awt.*;
- /**
- * Write a description of class MainList here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class MainList
- {
- //
- private LinkedList MAIN;
- private int depths;
- public LinkedList getList() {return MAIN;}
- /**
- * Constructor for objects of class MainList
- */
- public MainList()
- {
- //
- MAIN = new LinkedList<Sprite1>();
- }
- public void updateItem(Sprite1 S1)
- {
- S1.updateStats();
- S1.displayStats();
- }
- public void allListUpdate()
- {
- depths = 0;
- System.out.println();
- for(int fall = 0; fall < MAIN.size(); fall++)
- {
- depths = 1;
- System.out.print("List Depth: " + depths + " ");
- Sprite1 S1 = (Sprite1)MAIN.get(fall);
- System.out.print("Sprite : " + fall + "\t");
- updateItem(S1);
- if(S1.HSL())
- {
- System.out.println("Sprite1 : " + fall + "\n\tHas Sub List!" + "\n\t\tUpdating List of " + S1.getName().toUpperCase() + " Now!");
- updateSubLists(S1.getList());
- }
- }
- }
- private void updateSubLists(LinkedList SUB)
- {
- depths++;
- for(int fall = 0; fall < SUB.size(); fall++)
- {
- Sprite1 S1 = (Sprite1)SUB.get(fall);
- System.out.print("List Depth: " + depths + " ");
- System.out.print("Sprite : " + fall + "\t");
- updateItem(S1);
- if(S1.HSL())
- {
- System.out.println("Sprite1 : " + fall + "\n\tHas Sub List!" + "\n\t\tUpdating List of " + S1.getName().toUpperCase() + " Now!");
- updateSubLists(S1.getList());
- }
- }
- }
- //These two methods are still being worked on as will as a few others I'm going to put in.
- public Sprite1 getSprite(Sprite1 S1)
- {
- return S1;
- }
- public Sprite1 getSprite(int S1)
- {
- Sprite1 S2 = (Sprite1)MAIN.get(S1);
- return S2;
- }
- }
- //Main List Manager
- //Starter Object, aka a test object
- import java.util.*;
- import java.awt.*;
- /**
- * Write a description of class Sprite1 here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class Sprite1
- {
- //
- protected Random mix;
- protected String Name;
- protected int x, y, z, f;
- private static long NN;
- protected boolean hasSubList;
- protected LinkedList sub;
- public LinkedList getList() {return sub;}
- //private LinkedList AltLists;
- /**
- * Constructor for objects of class Sprite1
- */
- public Sprite1()
- {
- // initialise instance variables
- mix = new Random();
- Name = "Sprite " + NN;
- NN++;
- x = 0;
- y = 0;
- z = 0;
- f = 0;
- sub = new LinkedList<Sprite1>();
- }
- public void updateStats()
- {
- x += 1;
- y += 1;
- z += 1;
- f += 1;
- SubListOn();
- }
- public void displayStats()
- {
- System.out.println("Name: " + Name + " X = " + x + " Y = " + y + " Z = " + z + " F = " + f + " Has Sub List = " + HSL() + " List Size = " + sub.size());
- }
- private void SubListOn()
- {
- if(sub.size() > 0 && sub != null)
- {
- hasSubList = true;
- }
- else
- {
- hasSubList = false;
- }
- }
- public boolean HSL(){return hasSubList;}
- public String getName(){return Name;}
- public void setName(String N){Name = N;}
- //not sure If I'm going to need these or not as of yet. ?_?
- /*
- public void addSub(Sprite1 S1)
- {
- sub.add(S1);
- }
- public Sprite1 removeSub(Sprite1 S1)
- {
- if(S1 == null)
- {
- return null;
- }
- else
- {
- for(int n = 0; n < sub.size(); n++)
- {
- Sprite1 spr = (Sprite1) sub.get(n);
- if(spr.equals(S1) && (S1 != null && spr != null) )
- {
- sub.remove(n);
- }
- }
- return S1;
- }
- }
- public Sprite1 removeSub(int index)
- {
- Sprite1 spr = (Sprite1) sub.get(n);
- sub.remove(n);
- }
- public Sprite1 getSLS(Sprite1 me)
- {
- Sprite1 spr1 = me;
- if(me == null)
- {
- return null;
- }
- else
- {
- for(int n = 0; n < sub.size(); n++)
- {
- Sprite1 spr2 = (Sprite1) sub.get(n);
- if(spr2.equals(spr1) && (spr1 != null && spr2 != null) )
- {
- spr1 = spr2;
- }
- }
- return spr1;
- }
- }
- public Sprite1 getSLS(int index)
- {
- Sprite1 spr1 = (Sprite1)sub.get(index);
- if(spr1 == null)
- {
- return null;
- }
- else if(spr1 != null)
- {
- return spr1;
- }
- else
- {
- System.err.println("An error has occurred in getSLS!");
- return null;
- }
- }
- */
- }
- //Starter Object, aka a test object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement