From 265f50f78cd02a1bdf3038b3595846d1b67595a7 Mon Sep 17 00:00:00 2001 From: Lucas Estrella Date: Fri, 10 Feb 2017 18:23:14 -0500 Subject: [PATCH] Completed adding tabs to the java version of the lists. --- Hello_World_Tutorials/CDLL.html | 2 +- Hello_World_Tutorials/Java_CDLL.html | 64 ++- Hello_World_Tutorials/Java_CSLL.html | 388 +++--------------- Hello_World_Tutorials/Java_DLL.html | 320 +-------------- .../tutorial-source-code/cdllist.java | 67 ++- .../tutorial-source-code/csllist.java | 103 +++++ .../tutorial-source-code/dllist.java | 108 +++++ 7 files changed, 395 insertions(+), 657 deletions(-) create mode 100644 Hello_World_Tutorials/tutorial-source-code/csllist.java create mode 100644 Hello_World_Tutorials/tutorial-source-code/dllist.java diff --git a/Hello_World_Tutorials/CDLL.html b/Hello_World_Tutorials/CDLL.html index 9d0b4499e..c3dae7c6f 100644 --- a/Hello_World_Tutorials/CDLL.html +++ b/Hello_World_Tutorials/CDLL.html @@ -37,7 +37,7 @@

How does the CircDLelement<E> work?

that has two links, pointing to two other doubly linked elements. So a CircDLelement<E> “knows” who it’s pointing at, AND it knows who pointed at it. -



+



In this example, calling getNext() on CircDLelement2 will return CircDLelement3. Calling getPrev() on CircDLelement2 will return CircDLelement1. CircDLelement3 points to CircDLelement1, and CircDLelement1 points to CircDLelement3.

diff --git a/Hello_World_Tutorials/Java_CDLL.html b/Hello_World_Tutorials/Java_CDLL.html index 252e948c8..7830c4cb1 100644 --- a/Hello_World_Tutorials/Java_CDLL.html +++ b/Hello_World_Tutorials/Java_CDLL.html @@ -26,6 +26,59 @@

Inside our Main

positive integer), and the remaining two parameters are your BRIDGES credentials. You will need to replace the two fields in this call with your own BRIDGES credentials.

+

  • Now create an array to hold Student objects.
  • +
    +    Student[] students = {
    +            new Student(
    +                    "00000000000",
    +                    "Gretel Chaney",
    +                    "CS",
    +                    "g.chaney@generated.com",
    +                    "magenta",
    +                    "blue",
    +                    9.0,
    +                    "https://randomuser.me/api/portraits/med/women/45.jpg"
    +            ),
    +            new Student(
    +                    "00000000001",
    +                    "Karol Soderman",
    +                    "SIS",
    +                    "k.soderman@generated.com",
    +                    "magenta",
    +                    "red",
    +                    11.0,
    +                    "https://randomuser.me/api/portraits/med/women/46.jpg"
    +            ),
    +            new Student(
    +                    "00000000002",
    +                    "Lamont Kyler",
    +                    "BIO",
    +                    "l.kyler@generated.com",
    +                    "yellow",
    +                    "green",
    +                    12.0,
    +                    "https://randomuser.me/api/portraits/med/men/80.jpg"
    +            ),
    +            new Student(
    +                    "00000000003",
    +                    "Gladys Serino",
    +                    "CS","g.serino@generated.com",
    +                    "blue",
    +                    "magenta",
    +                    9.0,
    +                    "https://randomuser.me/api/portraits/med/women/2.jpg"
    +            ),
    +            new Student("00000000004",
    +                    "Starr Mcginn",
    +                    "CS",
    +                    "s.mcginn@generated.com",
    +                    "red",
    +                    "yellow",
    +                    15.0,
    +                    "https://randomuser.me/api/portraits/med/men/87.jpg")
    +    };
    +  
    +
  • Then we can create our CircDLelements with the Student objects and link the DLements together.
  •  
    @@ -34,11 +87,11 @@ 

    Inside our Main

    */ //initializing all elements with empty labels, and with the student data. See Object model.Student.java CircDLelement el0 = null; - for(int i = 0; i < StudentProvider.getStudents().length; i++) { + for(int i = 0; i < students.length; i++) { if(i > 0) { - el0 = insertFront(el0, new CircDLelement("",StudentProvider.getStudentAt(i))); + el0 = insertFront(el0, new CircDLelement("",students[i])); }else{ - el0 = new CircDLelement("",StudentProvider.getStudentAt(i)); + el0 = new CircDLelement("",students[i]); } } @@ -74,7 +127,6 @@

    Here's the final code:

    @@ -86,10 +138,6 @@

    Here's the final code:

    
             
    - -
    -
    
    -        
    diff --git a/Hello_World_Tutorials/Java_CSLL.html b/Hello_World_Tutorials/Java_CSLL.html index e97499e68..2d0ded700 100644 --- a/Hello_World_Tutorials/Java_CSLL.html +++ b/Hello_World_Tutorials/Java_CSLL.html @@ -26,20 +26,74 @@

    Inside our Main

    positive integer), and the remaining two parameters are your BRIDGES credentials. You will need to replace the two fields in this call with your own BRIDGES credentials.

    + +

  • Now create an array to hold Student objects.
  • +
    +      Student[] students = {
    +              new Student(
    +                      "00000000000",
    +                      "Gretel Chaney",
    +                      "CS",
    +                      "g.chaney@generated.com",
    +                      "magenta",
    +                      "blue",
    +                      9.0,
    +                      "https://randomuser.me/api/portraits/med/women/45.jpg"
    +              ),
    +              new Student(
    +                      "00000000001",
    +                      "Karol Soderman",
    +                      "SIS",
    +                      "k.soderman@generated.com",
    +                      "magenta",
    +                      "red",
    +                      11.0,
    +                      "https://randomuser.me/api/portraits/med/women/46.jpg"
    +              ),
    +              new Student(
    +                      "00000000002",
    +                      "Lamont Kyler",
    +                      "BIO",
    +                      "l.kyler@generated.com",
    +                      "yellow",
    +                      "green",
    +                      12.0,
    +                      "https://randomuser.me/api/portraits/med/men/80.jpg"
    +              ),
    +              new Student(
    +                      "00000000003",
    +                      "Gladys Serino",
    +                      "CS","g.serino@generated.com",
    +                      "blue",
    +                      "magenta",
    +                      9.0,
    +                      "https://randomuser.me/api/portraits/med/women/2.jpg"
    +              ),
    +              new Student("00000000004",
    +                      "Starr Mcginn",
    +                      "CS",
    +                      "s.mcginn@generated.com",
    +                      "red",
    +                      "yellow",
    +                      15.0,
    +                      "https://randomuser.me/api/portraits/med/men/87.jpg")
    +      };
    +    
    +
  • Then we can create our CircSLelements with the Student objects and link the DLements together.
  •  
    -    CircSLelement el0 = new CircSLelement("",StudentProvider.getStudentAt(0));
    +    /**
    +     * new CircSLelement<>(label, genericData)
    +     */
    +    CircSLelement el0 = new CircSLelement("",students[0]);
         CircSLelement current = el0;
     
    -    for(int i = 1; i < StudentProvider.getStudents().length; i++){
    -        if(i != StudentProvider.getStudents().length-1){
    -              current.setNext(new CircSLelement("",StudentProvider.getStudentAt(i)));
    -        }else{
    -
    -            //set the last element
    -            current.setNext(new CircSLelement("",StudentProvider.getStudentAt(i)));
    +    for(int i = 1; i < students.length; i++){
    +        current.setNext(new CircSLelement("", students[i]));
     
    +        //handles the last element
    +        if(i == students.length-1){
                 //getting the last element
                 current = current.getNext();
     
    @@ -77,331 +131,21 @@ 

    Inside our Main

    Here's the final code:

    +
    -
    -
    -  package csllist;
    -  /**
    -   * Created by Lucas Estrella on 1/31/2017.
    -   * lestrell@uncc.edu
    -   */
    -  import bridges.base.CircSLelement;
    -  import bridges.connect.Bridges;
    -  import model.Student;
    -  import provider.StudentProvider;
    -
    -  import java.io.FileNotFoundException;
    -
    -  public class Main {
    -
    -      public static void main(String[] args) {
    -
    -          Bridges bridge = new Bridges(3, "YOUR_API_KEY", "YOUR_USER_ID");
    -
    -
    -          /**
    -           * new CircSLelement<>(label, genericData)
    -           */
    -          CircSLelement el0 = new CircSLelement("",StudentProvider.getStudentAt(0));
    -          CircSLelement current = el0;
    -
    -          for(int i = 1; i < StudentProvider.getStudents().length; i++){
    -              if(i != StudentProvider.getStudents().length-1){
    -                    current.setNext(new CircSLelement("",StudentProvider.getStudentAt(i)));
    -              }else{
    -
    -                  //set the last element
    -                  current.setNext(new CircSLelement("",StudentProvider.getStudentAt(i)));
    -
    -                  //getting the last element
    -                  current = current.getNext();
    -
    -                  //point the last element to the first element, so the list becomes circular.
    -                  current.getNext().setNext(el0);
    -              }
    -
    -              //set the current element to be the next element
    -              current = current.getNext();
    -          }
    -
    -          current = el0;
    -
    -          do{
    -              current.setLabel(current.getValue().getStudentLabel());
    -              current.getVisualizer().setColor(current.getValue().getFavoriteColor());
    -
    -              current.getLinkVisualizer(current.getNext()).setColor(current.getValue().getDislikeColor());
    -              current.getLinkVisualizer(current.getNext()).setThickness(current.getValue().getStudentCreditHours()*0.75);
    -
    -              current = current.getNext();
    -          }while(current.getIdentifier() != el0.getIdentifier());
    -
    -          bridge.setDataStructure(el0);
    -          bridge.visualize();
    -
    -      }
    -
    -  }
    -
    -
    -
    -
    -
    -
    -  package model;
    -
    -  /**
    -   * Created by Lucas Estrella on 1/31/2017.
    -   */
    -  public class Student {
    -      private String studentID,
    -                     fullName,
    -                     program,
    -                     email,
    -                     dislikeColor,
    -                     favoriteColor,
    -                     avatar;
    -
    -      private boolean visited;
    -
    -      public boolean isVisited() {
    -          return visited;
    -      }
    -
    -      public void setVisited(boolean visited) {
    -          this.visited = visited;
    -      }
    -
    -      private double studentCreditHours;
    -
    -      /**
    -       * @param studentID
    -       * @param fullName
    -       * @param program
    -       * @param email
    -       */
    -      public Student(String studentID,
    -                     String fullName,
    -                     String program,
    -                     String email,
    -                     String dislikeColor,
    -                     String favoriteColor,
    -                     double studentCreditHours,
    -                     String avatar) {
    -          this.studentID = studentID;
    -          this.fullName = fullName;
    -          this.program = program;
    -          this.email = email;
    -          this.dislikeColor = dislikeColor;
    -          this.favoriteColor = favoriteColor;
    -          this.studentCreditHours = studentCreditHours;
    -          this.avatar = avatar;
    -      }
    -
    -      /**
    -       * @return studentID
    -       */
    -      public String getStudentID() {
    -          return studentID;
    -      }
    -
    -      /**
    -       * @param studentID
    -       */
    -      public void setStudentID(String studentID) {
    -          this.studentID = studentID;
    -      }
    -
    -      /**
    -       * @return fullName
    -       */
    -      public String getFullName() {
    -          return fullName;
    -      }
    -
    -      /**
    -       * @param fullName
    -       */
    -      public void setFullName(String fullName) {
    -          this.fullName = fullName;
    -      }
    -
    -      /**
    -       * @return program
    -       */
    -      public String getProgram() {
    -          return program;
    -      }
    -
    -      /**
    -       * @param program
    -       */
    -      public void setProgram(String program) {
    -          this.program = program;
    -      }
    -
    -      /**
    -       * @return email
    -       */
    -      public String getEmail() {
    -          return email;
    -      }
    -
    -      /**
    -       * @param email
    -       */
    -      public void setEmail(String email) {
    -          this.email = email;
    -      }
    -
    -
    -      /**
    -       * @return favoriteColor
    -       */
    -      public String getFavoriteColor() {
    -          return favoriteColor;
    -      }
    -
    -      /**
    -       * @param favoriteColor
    -       */
    -      public void setFavoriteColor(String favoriteColor) {
    -          this.favoriteColor = favoriteColor;
    -      }
    -
    -
    -      public String getAvatar() {
    -          return avatar;
    -      }
    -
    -      public void setAvatar(String avatar) {
    -          this.avatar = avatar;
    -      }
    -
    -      public String getDislikeColor() {
    -          return dislikeColor;
    -      }
    -
    -      public void setDislikeColor(String dislikeColor) {
    -          this.dislikeColor = dislikeColor;
    -      }
    -
    -      public double getStudentCreditHours() {
    -          return studentCreditHours;
    -      }
    -
    -      public void setStudentCreditHours(double studentCreditHours) {
    -          this.studentCreditHours = studentCreditHours;
    -      }
    -
    -      public String getStudentLabel() {
    -          String $label =
    -                                             fullName      +  "\n"   +
    -                                 "Email: " + email         +  "\n"   +
    -                               "Program: " + program       +  "\n"   +
    -                            "Student ID: " + studentID     +  "\n"   +
    -                        "Favorite Color: " + favoriteColor +  "\n";
    -
    -          if(avatar != null)
    -              $label += "<img width='100' src='" + avatar        +  "'/>";
    -
    -
    -          return $label;
    -      }
    -  }
    -
    -
    +
    
             
    -
    -
    -  package provider;
    -
    -  import model.Student;
    -
    -  /**
    -   * Created by Lucas Estrella on 2/2/2017.
    -   */
    -  public class StudentProvider {
    -
    -      /**
    -       * @param index
    -       * @return student at index
    -       */
    -      public static Student getStudentAt(int index){
    -          if(index >= students.length){
    -              throw new NullPointerException();
    -          }
    -          return students[index];
    -      }
    -
    -      /**
    -       * @return all students
    -       */
    -      public static Student[] getStudents(){
    -          return students;
    -      }
    -
    -      private static Student[] students = {
    -              new Student(
    -                      "00000000000",
    -                      "Gretel Chaney",
    -                      "CS",
    -                      "g.chaney@generated.com",
    -                      "magenta",
    -                      "blue",
    -                      9.0,
    -                      "https://randomuser.me/api/portraits/med/women/45.jpg"
    -              ),
    -              new Student(
    -                      "00000000001",
    -                      "Karol Soderman",
    -                      "SIS",
    -                      "k.soderman@generated.com",
    -                      "magenta",
    -                      "red",
    -                      11.0,
    -                      "https://randomuser.me/api/portraits/med/women/46.jpg"
    -              ),
    -              new Student(
    -                      "00000000002",
    -                      "Lamont Kyler",
    -                      "BIO",
    -                      "l.kyler@generated.com",
    -                      "yellow",
    -                      "green",
    -                      12.0,
    -                      "https://randomuser.me/api/portraits/med/men/80.jpg"
    -              ),
    -              new Student(
    -                      "00000000003",
    -                      "Gladys Serino",
    -                      "CS","g.serino@generated.com",
    -                      "blue",
    -                      "magenta",
    -                      9.0,
    -                      "https://randomuser.me/api/portraits/med/women/2.jpg"
    -              ),
    -              new Student("00000000004",
    -                      "Starr Mcginn",
    -                      "CS",
    -                      "s.mcginn@generated.com",
    -                      "red",
    -                      "yellow",
    -                      15.0,
    -                      "https://randomuser.me/api/portraits/med/men/87.jpg")
    -      };
    -  }
     
    -
    +
    +
    
             
    diff --git a/Hello_World_Tutorials/Java_DLL.html b/Hello_World_Tutorials/Java_DLL.html index 7e0ff1a13..14cb74e04 100644 --- a/Hello_World_Tutorials/Java_DLL.html +++ b/Hello_World_Tutorials/Java_DLL.html @@ -71,334 +71,22 @@

    Inside our Main

    -

    Here's the final code:

    +

    Here's the final code:

    -
    -package dllist;
    -/**
    -* Created by Lucas Estrella on 1/31/2017.
    -* lestrell@uncc.edu
    -*/
    -import bridges.base.DLelement;
    -import bridges.connect.Bridges;
    -import model.Student;
    -import provider.StudentProvider;
    -
    -public class Main {
    -
    -  public static void main(String[] args) throws , ParseException {
    -
    -      Bridges bridge = new Bridges(2, "YOUR_API_KEY", "YOUR_USER_ID");
    -
    -      /**
    -       * new DLelement<>(label, genericData)
    -       */
    -
    -      //initializing all elements with empty labels, and with the student data. See Object model.Student.java
    -      DLelement el0 = null;
    -
    -        for(int i = 0; i < StudentProvider.getStudents().length; i++){
    -            if(i > 1){
    -                el0 = insertFront(el0, new DLelement<>("",StudentProvider.getStudentAt(i)));
    -            }else if(i == 0){
    -                el0 = new DLelement<>("",StudentProvider.getStudentAt(0));
    -                el0.setNext(new DLelement<>("",StudentProvider.getStudentAt(1)));
    -            }
    -        }
    -
    -        DLelement current = el0;
    -        while(current != null){
    -            current.setLabel(current.getValue().getStudentLabel());
    -            current.getVisualizer().setColor(current.getValue().getFavoriteColor());
    -
    -            if(current.getNext() != null)current.getLinkVisualizer(current.getNext()).setColor(current.getValue().getDislikeColor());
    -            if(current.getPrev() != null)current.getLinkVisualizer(current.getPrev()).setColor(current.getValue().getDislikeColor());
    -
    -            current = current.getNext();
    -        }
    -
    -      bridge.setDataStructure(el0);
    -      bridge.visualize();
    -
    -
    -  }
    -
    -  public static DLelement insertFront(DLelement tail,
    -                                      DLelement newElement){
    -      DLelement tailNext = tail.getNext();
    -
    -      newElement.setNext(tailNext);
    -      newElement.setPrev(tail);
    -
    -      tailNext.setPrev(newElement);
    -      tail.setNext(newElement);
    -      return tail;
    -  }
    -
    -
    -
    -
    -
    -}
    -
    +
    
             
    -
    -
    -  package model;
    -
    -  /**
    -   * Created by Lucas Estrella on 1/31/2017.
    -   */
    -  public class Student {
    -      private String studentID,
    -                     fullName,
    -                     program,
    -                     email,
    -                     dislikeColor,
    -                     favoriteColor,
    -                     avatar;
    -
    -      private boolean visited;
    -
    -      public boolean isVisited() {
    -          return visited;
    -      }
    -
    -      public void setVisited(boolean visited) {
    -          this.visited = visited;
    -      }
    -
    -      private double studentCreditHours;
    -
    -      /**
    -       * @param studentID
    -       * @param fullName
    -       * @param program
    -       * @param email
    -       */
    -      public Student(String studentID,
    -                     String fullName,
    -                     String program,
    -                     String email,
    -                     String dislikeColor,
    -                     String favoriteColor,
    -                     double studentCreditHours,
    -                     String avatar) {
    -          this.studentID = studentID;
    -          this.fullName = fullName;
    -          this.program = program;
    -          this.email = email;
    -          this.dislikeColor = dislikeColor;
    -          this.favoriteColor = favoriteColor;
    -          this.studentCreditHours = studentCreditHours;
    -          this.avatar = avatar;
    -      }
    -
    -      /**
    -       * @return studentID
    -       */
    -      public String getStudentID() {
    -          return studentID;
    -      }
     
    -      /**
    -       * @param studentID
    -       */
    -      public void setStudentID(String studentID) {
    -          this.studentID = studentID;
    -      }
    -
    -      /**
    -       * @return fullName
    -       */
    -      public String getFullName() {
    -          return fullName;
    -      }
    -
    -      /**
    -       * @param fullName
    -       */
    -      public void setFullName(String fullName) {
    -          this.fullName = fullName;
    -      }
    -
    -      /**
    -       * @return program
    -       */
    -      public String getProgram() {
    -          return program;
    -      }
    -
    -      /**
    -       * @param program
    -       */
    -      public void setProgram(String program) {
    -          this.program = program;
    -      }
    -
    -      /**
    -       * @return email
    -       */
    -      public String getEmail() {
    -          return email;
    -      }
    -
    -      /**
    -       * @param email
    -       */
    -      public void setEmail(String email) {
    -          this.email = email;
    -      }
    -
    -
    -      /**
    -       * @return favoriteColor
    -       */
    -      public String getFavoriteColor() {
    -          return favoriteColor;
    -      }
    -
    -      /**
    -       * @param favoriteColor
    -       */
    -      public void setFavoriteColor(String favoriteColor) {
    -          this.favoriteColor = favoriteColor;
    -      }
    -
    -
    -      public String getAvatar() {
    -          return avatar;
    -      }
    -
    -      public void setAvatar(String avatar) {
    -          this.avatar = avatar;
    -      }
    -
    -      public String getDislikeColor() {
    -          return dislikeColor;
    -      }
    -
    -      public void setDislikeColor(String dislikeColor) {
    -          this.dislikeColor = dislikeColor;
    -      }
    -
    -      public double getStudentCreditHours() {
    -          return studentCreditHours;
    -      }
    -
    -      public void setStudentCreditHours(double studentCreditHours) {
    -          this.studentCreditHours = studentCreditHours;
    -      }
    -
    -      public String getStudentLabel() {
    -          String $label =
    -                                             fullName      +  "\n"   +
    -                                 "Email: " + email         +  "\n"   +
    -                               "Program: " + program       +  "\n"   +
    -                            "Student ID: " + studentID     +  "\n"   +
    -                        "Favorite Color: " + favoriteColor +  "\n";
    -
    -          if(avatar != null)
    -              $label += "<img width='100' src='" + avatar        +  "'/>";
    -
    -
    -          return $label;
    -      }
    -  }
    -
    -
    -
    -
    -
    -  package provider;
    -
    -  import model.Student;
    -
    -  /**
    -   * Created by Lucas Estrella on 2/2/2017.
    -   */
    -  public class StudentProvider {
    -
    -      /**
    -       * @param index
    -       * @return student at index
    -       */
    -      public static Student getStudentAt(int index){
    -          if(index >= students.length){
    -              throw new NullPointerException();
    -          }
    -          return students[index];
    -      }
    -
    -      /**
    -       * @return all students
    -       */
    -      public static Student[] getStudents(){
    -          return students;
    -      }
    -
    -      private static Student[] students = {
    -              new Student(
    -                      "00000000000",
    -                      "Gretel Chaney",
    -                      "CS",
    -                      "g.chaney@generated.com",
    -                      "magenta",
    -                      "blue",
    -                      9.0,
    -                      "https://randomuser.me/api/portraits/med/women/45.jpg"
    -              ),
    -              new Student(
    -                      "00000000001",
    -                      "Karol Soderman",
    -                      "SIS",
    -                      "k.soderman@generated.com",
    -                      "magenta",
    -                      "red",
    -                      11.0,
    -                      "https://randomuser.me/api/portraits/med/women/46.jpg"
    -              ),
    -              new Student(
    -                      "00000000002",
    -                      "Lamont Kyler",
    -                      "BIO",
    -                      "l.kyler@generated.com",
    -                      "yellow",
    -                      "green",
    -                      12.0,
    -                      "https://randomuser.me/api/portraits/med/men/80.jpg"
    -              ),
    -              new Student(
    -                      "00000000003",
    -                      "Gladys Serino",
    -                      "CS","g.serino@generated.com",
    -                      "blue",
    -                      "magenta",
    -                      9.0,
    -                      "https://randomuser.me/api/portraits/med/women/2.jpg"
    -              ),
    -              new Student("00000000004",
    -                      "Starr Mcginn",
    -                      "CS",
    -                      "s.mcginn@generated.com",
    -                      "red",
    -                      "yellow",
    -                      15.0,
    -                      "https://randomuser.me/api/portraits/med/men/87.jpg")
    -      };
    -  }
    -
    -
    +
    +
    
             
    diff --git a/Hello_World_Tutorials/tutorial-source-code/cdllist.java b/Hello_World_Tutorials/tutorial-source-code/cdllist.java index 7cac10f8b..7dc2e6192 100644 --- a/Hello_World_Tutorials/tutorial-source-code/cdllist.java +++ b/Hello_World_Tutorials/tutorial-source-code/cdllist.java @@ -1,29 +1,75 @@ package cdllist; -/** -* Created by Lucas Estrella on 1/31/2017. -* lestrell@uncc.edu -*/ + import bridges.base.CircDLelement; import bridges.connect.Bridges; import model.Student; -import provider.StudentProvider; public class Main { public static void main(String[] args) throws , ParseException { - Bridges bridge = new Bridges(4, "YOUR_API_KEY", "YOUR_USER_ID"); + Bridges bridge = new Bridges(6, "YOUR_API_KEY", "YOUR_USER_ID"); + + Student[] students = { + new Student( + "00000000000", + "Gretel Chaney", + "CS", + "g.chaney@generated.com", + "magenta", + "blue", + 9.0, + "https://randomuser.me/api/portraits/med/women/45.jpg" + ), + new Student( + "00000000001", + "Karol Soderman", + "SIS", + "k.soderman@generated.com", + "magenta", + "red", + 11.0, + "https://randomuser.me/api/portraits/med/women/46.jpg" + ), + new Student( + "00000000002", + "Lamont Kyler", + "BIO", + "l.kyler@generated.com", + "yellow", + "green", + 12.0, + "https://randomuser.me/api/portraits/med/men/80.jpg" + ), + new Student( + "00000000003", + "Gladys Serino", + "CS","g.serino@generated.com", + "blue", + "magenta", + 9.0, + "https://randomuser.me/api/portraits/med/women/2.jpg" + ), + new Student("00000000004", + "Starr Mcginn", + "CS", + "s.mcginn@generated.com", + "red", + "yellow", + 15.0, + "https://randomuser.me/api/portraits/med/men/87.jpg") + }; /** * new CircDLelement<>(label, genericData) */ //initializing all elements with empty labels, and with the student data. See Object model.Student.java CircDLelement el0 = null; - for(int i = 0; i < StudentProvider.getStudents().length; i++) { + for(int i = 0; i < students.length; i++) { if(i > 0) { - el0 = insertFront(el0, new CircDLelement("",StudentProvider.getStudentAt(i))); + el0 = insertFront(el0, new CircDLelement("",students[i])); }else{ - el0 = new CircDLelement("",StudentProvider.getStudentAt(i)); + el0 = new CircDLelement("",students[i]); } } @@ -59,4 +105,5 @@ public static CircDLelement insertFront(CircDLelement tailElement, tailElement.setNext(newElement); return tailElement; } -} \ No newline at end of file + +} diff --git a/Hello_World_Tutorials/tutorial-source-code/csllist.java b/Hello_World_Tutorials/tutorial-source-code/csllist.java new file mode 100644 index 000000000..a95513631 --- /dev/null +++ b/Hello_World_Tutorials/tutorial-source-code/csllist.java @@ -0,0 +1,103 @@ +package csllist; + +import bridges.base.CircDLelement; +import bridges.connect.Bridges; +import model.Student; + +public class Main { + + public static void main(String[] args) throws , ParseException { + + Bridges bridge = new Bridges(5, "YOUR_API_KEY", "YOUR_USER_ID"); + + Student[] students = { + new Student( + "00000000000", + "Gretel Chaney", + "CS", + "g.chaney@generated.com", + "magenta", + "blue", + 9.0, + "https://randomuser.me/api/portraits/med/women/45.jpg" + ), + new Student( + "00000000001", + "Karol Soderman", + "SIS", + "k.soderman@generated.com", + "magenta", + "red", + 11.0, + "https://randomuser.me/api/portraits/med/women/46.jpg" + ), + new Student( + "00000000002", + "Lamont Kyler", + "BIO", + "l.kyler@generated.com", + "yellow", + "green", + 12.0, + "https://randomuser.me/api/portraits/med/men/80.jpg" + ), + new Student( + "00000000003", + "Gladys Serino", + "CS","g.serino@generated.com", + "blue", + "magenta", + 9.0, + "https://randomuser.me/api/portraits/med/women/2.jpg" + ), + new Student("00000000004", + "Starr Mcginn", + "CS", + "s.mcginn@generated.com", + "red", + "yellow", + 15.0, + "https://randomuser.me/api/portraits/med/men/87.jpg") + }; + + /** + * new CircSLelement<>(label, genericData) + */ + CircSLelement el0 = new CircSLelement("",students[0]); + CircSLelement current = el0; + + for(int i = 1; i < students.length; i++){ + current.setNext(new CircSLelement("", students[i])); + + //handles the last element + if(i == students.length-1){ + //getting the last element + current = current.getNext(); + + //point the last element to the first element, so the list becomes circular. + current.getNext().setNext(el0); + } + + //set the current element to be the next element + current = current.getNext(); + } + + + current = el0; + + do{ + current.setLabel(current.getValue().getStudentLabel()); + current.getVisualizer().setColor(current.getValue().getFavoriteColor()); + + current.getLinkVisualizer(current.getNext()).setColor(current.getValue().getDislikeColor()); + current.getLinkVisualizer(current.getNext()).setThickness(current.getValue().getStudentCreditHours()*0.75); + + current = current.getNext(); + }while(current.getIdentifier() != el0.getIdentifier()); + + bridge.setDataStructure(el0); + bridge.visualize(); + + } + +} diff --git a/Hello_World_Tutorials/tutorial-source-code/dllist.java b/Hello_World_Tutorials/tutorial-source-code/dllist.java new file mode 100644 index 000000000..7c658fa11 --- /dev/null +++ b/Hello_World_Tutorials/tutorial-source-code/dllist.java @@ -0,0 +1,108 @@ +package dllist; + +import bridges.base.CircDLelement; +import bridges.connect.Bridges; +import model.Student; + +public class Main { + + public static void main(String[] args) throws , ParseException { + + Bridges bridge = new Bridges(4, "YOUR_API_KEY", "YOUR_USER_ID"); + + Student[] students = { + new Student( + "00000000000", + "Gretel Chaney", + "CS", + "g.chaney@generated.com", + "magenta", + "blue", + 9.0, + "https://randomuser.me/api/portraits/med/women/45.jpg" + ), + new Student( + "00000000001", + "Karol Soderman", + "SIS", + "k.soderman@generated.com", + "magenta", + "red", + 11.0, + "https://randomuser.me/api/portraits/med/women/46.jpg" + ), + new Student( + "00000000002", + "Lamont Kyler", + "BIO", + "l.kyler@generated.com", + "yellow", + "green", + 12.0, + "https://randomuser.me/api/portraits/med/men/80.jpg" + ), + new Student( + "00000000003", + "Gladys Serino", + "CS","g.serino@generated.com", + "blue", + "magenta", + 9.0, + "https://randomuser.me/api/portraits/med/women/2.jpg" + ), + new Student("00000000004", + "Starr Mcginn", + "CS", + "s.mcginn@generated.com", + "red", + "yellow", + 15.0, + "https://randomuser.me/api/portraits/med/men/87.jpg") + }; + + /** + * new DLelement<>(label, genericData) + */ + //initializing all elements with empty labels, and with the student data. See Object model.Student.java + DLelement el0 = null; + + for(int i = 0; i < students.length; i++){ + if(i > 1){ + el0 = insertFront(el0, new DLelement<>("",students[i])); + }else if(i == 0){ + el0 = new DLelement<>("",students[0]); + el0.setNext(new DLelement<>("",students[1])); + } + } + + DLelement current = el0; + while(current != null){ + current.setLabel(current.getValue().getStudentLabel()); + current.getVisualizer().setColor(current.getValue().getFavoriteColor()); + + if(current.getNext() != null)current.getLinkVisualizer(current.getNext()).setColor(current.getValue().getDislikeColor()); + if(current.getPrev() != null)current.getLinkVisualizer(current.getPrev()).setColor(current.getValue().getDislikeColor()); + + current = current.getNext(); + } + + bridge.setDataStructure(el0); + bridge.visualize(); + + + } + + + public static DLelement insertFront(DLelement tail, + DLelement newElement){ + DLelement tailNext = tail.getNext(); + + newElement.setNext(tailNext); + newElement.setPrev(tail); + + tailNext.setPrev(newElement); + tail.setNext(newElement); + return tail; + } + +}