diff --git a/Hello_World_Tutorials/Java_CDLL.html b/Hello_World_Tutorials/Java_CDLL.html index 73e59a604..252e948c8 100644 --- a/Hello_World_Tutorials/Java_CDLL.html +++ b/Hello_World_Tutorials/Java_CDLL.html @@ -80,318 +80,20 @@
-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"); - - /** - * 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++) { - if(i > 0) { - el0 = insertFront(el0, new CircDLelement("",StudentProvider.getStudentAt(i))); - }else{ - el0 = new CircDLelement("",StudentProvider.getStudentAt(i)); - } - } - - CircDLelement 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()*.75); - - current.getLinkVisualizer(current.getPrev()).setColor(current.getValue().getDislikeColor()); - current.getLinkVisualizer(current.getPrev()).setThickness(current.getValue().getStudentCreditHours()*.75); - - current = current.getNext(); - }while(current.getIdentifier() != el0.getIdentifier()); - - bridge.setDataStructure(el0); - bridge.visualize(); - - - } - - - public static CircDLelement insertFront(CircDLelement tailElement, - CircDLelement newElement){ - CircDLelement tailNextElement = tailElement.getNext(); - - newElement.setNext(tailNextElement); - newElement.setPrev(tailElement); - - tailNextElement.setPrev(newElement); - tailElement.setNext(newElement); - return tailElement; - } -} -
- 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") - }; - } - -+
SLelementel0 = new SLelement ( "", new StudentInfo( - "00000000000", - "Gretel Chaney", - "CS", - "g.chaney@generated.com", - "magenta", - "blue", + "00000000000", + "Gretel Chaney", + "CS", + "g.chaney@generated.com", + "magenta", + "blue", 9.0, "https://randomuser.me/api/portraits/med/women/45.jpg" )); SLelement el1 = new SLelement ( "", - new StudentInfo( - "00000000001", - "Karol Soderman", - "SIS", - "k.soderman@generated.com", - "magenta", - "red", + new StudentInfo( + "00000000001", + "Karol Soderman", + "SIS", + "k.soderman@generated.com", + "magenta", + "red", 11.0, "https://randomuser.me/api/portraits/med/women/46.jpg" )); SLelement el2 = new SLelement ( "", - new StudentInfo( - "00000000002", - "Lamont Kyler", - "BIO", + new StudentInfo( + "00000000002", + "Lamont Kyler", + "BIO", "l.kyler@generated.com", - "yellow", - "green", + "yellow", + "green", 12.0, "https://randomuser.me/api/portraits/med/men/80.jpg" )); SLelement el3 = new SLelement ( "", - new StudentInfo( - "00000000003", - "Gladys Serino", + new StudentInfo( + "00000000003", + "Gladys Serino", "CS", - "g.serino@generated.com", - "blue", - "magenta", + "g.serino@generated.com", + "blue", + "magenta", 9.0, "https://randomuser.me/api/portraits/med/women/2.jpg" )); SLelement el4 = new SLelement ( "", new StudentInfo( - "00000000004", - "Starr Mcginn", - "CS", - "s.mcginn@generated.com", - "red", - "yellow", + "00000000004", + "Starr Mcginn", + "CS", + "s.mcginn@generated.com", + "red", + "yellow", 15.0, "https://randomuser.me/api/portraits/med/men/87.jpg" )); @@ -105,11 +105,11 @@ Inside our Main
if(currentElement.getNext() != null){ currentElement.getLinkVisualizer(currentElement.getNext()) .setColor(currentElement.getValue().getDislikeColor()); - + currentElement.getLinkVisualizer(currentElement.getNext()) .setThickness(currentElement.getValue().getStudentCreditHours() * 0.75);//75 percent thinner } - + // set the label of the element to print student info currentElement.setLabel( currentElement.getValue().getFullName() + "\n"+ @@ -129,71 +129,33 @@Inside our Main
StudentInfo Class
- Next we illustrate the StudentInfo class below
--public class StudentInfo { - private String studentID, fullName, program, email, dislikeColor, favoriteColor, avatar; - private double studentCreditHours; - - public StudentInfo(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; - } - public String getStudentID() { - return studentID; - } - public void setStudentID(String studentID) { - this.studentID = studentID; - } - public String getFullName() { - return fullName; - } - public void setFullName(String fullName) { - this.fullName = fullName; - } - public String getProgram() { - return program; - } - public void setProgram(String program) { - this.program = program; - } + - public String getEmail() { - return email; - } - public void setEmail(String email) { - this.email = email; - } - public String getFavoriteColor() { - return 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; - } -} -+ + + +Here's the final code:
+ +++ +++ + + diff --git a/Hello_World_Tutorials/SLL.html b/Hello_World_Tutorials/SLL.html index 01dde6c94..9e5a65a7f 100644 --- a/Hello_World_Tutorials/SLL.html +++ b/Hello_World_Tutorials/SLL.html @@ -7,9 +7,13 @@ - + + + + + + - @@ -28,21 +32,21 @@+++ ++ ++ ++
How does the SLelement<E> work?
-SLelement<E> stands for Singly Linked Element and is a type -of container that has one link, pointing to another SLelement<E>. -So an SLelement<E> "knows" who it is pointing at but it does not know -who is pointing at it(if any). +SLelement<E> stands for Singly Linked Element and is a type +of container that has one link, pointing to another SLelement<E>. +So an SLelement<E> "knows" who it is pointing at but it does not know +who is pointing at it(if any).
-In the above example, SLelement1 points to SLelement2. Calling getNext() -on SLelement1 will return a link to SLelement2, and calling getNext() on -SLelement2 will return a link to SLelement3. SLelement3 is not pointing -to another SLelement so calling getNext() on SLelement3 will return NULL. -This is desirable since you will know that you have reached the end of the +In the above example, SLelement1 points to SLelement2. Calling getNext() +on SLelement1 will return a link to SLelement2, and calling getNext() on +SLelement2 will return a link to SLelement3. SLelement3 is not pointing +to another SLelement so calling getNext() on SLelement3 will return NULL. +This is desirable since you will know that you have reached the end of the singly linked list (as NULL is a unique value and not a legal memory address for an object).
-Also notice that there is no getPrev(). SLelement2 has no idea what -element came before it. So, you CANNOT go backwards. +Also notice that there is no getPrev(). SLelement2 has no idea what +element came before it. So, you CANNOT go backwards.
@@ -56,19 +60,19 @@SLelement - An Example BRIDGES program