commit bf2ab282055b6d2020ee095b1b52d8eaf12693d3 Author: Muhamed H. Asadi Date: Sun Oct 9 06:19:03 2022 +0330 Initial commit diff --git a/s1/.editorconfig b/s1/.editorconfig new file mode 100644 index 0000000..e1d0ce7 --- /dev/null +++ b/s1/.editorconfig @@ -0,0 +1,17 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 + +[*.sh] +end_of_line = lf + +[*.java] +indent_size = 4 +max_line_length = 120 diff --git a/s1/pom.xml b/s1/pom.xml new file mode 100644 index 0000000..0792faf --- /dev/null +++ b/s1/pom.xml @@ -0,0 +1,173 @@ + + 4.0.0 + com.tabrizu.data + s1 + 1.0 + + 1.8 + 1.8 + UTF-8 + 5.6.0 + 3.0.0-M3 + 3.1.2 + 8.45.1 + 3.0.0-M5 + 0.8.4 + 3.0.0 + + 0% + 0% + 20 + 5 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + + enforce + + + + + 3.6.3 + + + true + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.ngeor + checkstyle-rules + 4.9.3 + + + + com/github/ngeor/checkstyle.xml + true + ${skipTests} + + + + checkstyle + validate + + check + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + pre-unit-test + + prepare-agent + + + + post-unit-test + test + + report + + + + check-unit-test + test + + check + + + ${project.build.directory}/jacoco.exec + + + BUNDLE + + + INSTRUCTION + COVEREDRATIO + ${jacoco.unit-tests.limit.instruction-ratio} + + + BRANCH + COVEREDRATIO + ${jacoco.unit-tests.limit.branch-ratio} + + + + + CLASS + + + COMPLEXITY + TOTALCOUNT + ${jacoco.unit-tests.limit.class-complexity} + + + + + METHOD + + + COMPLEXITY + TOTALCOUNT + ${jacoco.unit-tests.limit.method-complexity} + + + + + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + + diff --git a/s1/src/main/java/com/tabrizu/data/App.java b/s1/src/main/java/com/tabrizu/data/App.java new file mode 100644 index 0000000..b53c142 --- /dev/null +++ b/s1/src/main/java/com/tabrizu/data/App.java @@ -0,0 +1,30 @@ +package com.tabrizu.data; + +/** + * Hello world! + */ +public final class App { + private App() { + } + + public static void main(String[] args) { + + ScoreBoard board = new ScoreBoard(); + + for (int i = 0; i < 100; i++) { + + Score randomScore = new Score("user"+String.valueOf(i)); + randomScore.setScore((int)(Math.random() * 100)); + + board.insertNewScore(randomScore); + } + + for (int i = 0; i < 10; i++) { + + String userName = "user"+String.valueOf((int)(Math.random() * 100)) + board.removeUser(userName); + } + + board.show(); + } +} diff --git a/s1/src/main/java/com/tabrizu/data/Score.java b/s1/src/main/java/com/tabrizu/data/Score.java new file mode 100644 index 0000000..3544441 --- /dev/null +++ b/s1/src/main/java/com/tabrizu/data/Score.java @@ -0,0 +1,32 @@ +package com.tabrizu.data; + +public class Score { + + private int m_score; + private String m_username; + + private Score(){} + + public Score(String username){ + m_username = username; + m_score = 0; + } + + public String getUsername(){ + return m_username; + } + + public void setScore(int score){ + m_score = score; + } + + public int getScore(){ + return m_score; + } + + @Override + public String toString(){ + return m_username + " : " + String.valueOf(m_score); + } + +} diff --git a/s1/src/main/java/com/tabrizu/data/ScoreBoard.java b/s1/src/main/java/com/tabrizu/data/ScoreBoard.java new file mode 100644 index 0000000..388648d --- /dev/null +++ b/s1/src/main/java/com/tabrizu/data/ScoreBoard.java @@ -0,0 +1,37 @@ +package com.tabrizu.data; + +public class ScoreBoard { + + private static final int SCORE_SIZE = 10; + + Score[] m_board; + int m_boardIndex; + + public ScoreBoard(){ + m_boardIndex = 0; + m_board = new Score[SCORE_SIZE]; + } + + public void insertNewScore(Score score){ + + } + + public void removeUser(String username){ + + } + + public void show(){ + System.out.print(this); + } + + @Override + public String toString(){ + + String str = ""; + for (int i = 0; i < m_boardIndex; i++) { + str += String.valueOf(i+1) + " => " + String.valueOf(m_board[i]) + "\n"; + } + return str; + } + +} diff --git a/s1/src/test/java/com/tabrizu/data/AppTest.java b/s1/src/test/java/com/tabrizu/data/AppTest.java new file mode 100644 index 0000000..e3a2610 --- /dev/null +++ b/s1/src/test/java/com/tabrizu/data/AppTest.java @@ -0,0 +1,18 @@ +package com.tabrizu.data; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Unit test for simple App. + */ +class AppTest { + /** + * Rigorous Test. + */ + @Test + void testApp() { + assertEquals(1, 1); + } +} diff --git a/s1/target/classes/com/tabrizu/data/App.class b/s1/target/classes/com/tabrizu/data/App.class new file mode 100644 index 0000000..f7e0ca2 Binary files /dev/null and b/s1/target/classes/com/tabrizu/data/App.class differ diff --git a/s1/target/classes/com/tabrizu/data/Score.class b/s1/target/classes/com/tabrizu/data/Score.class new file mode 100644 index 0000000..1aedcaf Binary files /dev/null and b/s1/target/classes/com/tabrizu/data/Score.class differ diff --git a/s1/target/classes/com/tabrizu/data/ScoreBoard.class b/s1/target/classes/com/tabrizu/data/ScoreBoard.class new file mode 100644 index 0000000..cbfb5d1 Binary files /dev/null and b/s1/target/classes/com/tabrizu/data/ScoreBoard.class differ diff --git a/s1/target/test-classes/com/tabrizu/data/AppTest.class b/s1/target/test-classes/com/tabrizu/data/AppTest.class new file mode 100644 index 0000000..7cf1701 Binary files /dev/null and b/s1/target/test-classes/com/tabrizu/data/AppTest.class differ diff --git a/sll/.editorconfig b/sll/.editorconfig new file mode 100644 index 0000000..e1d0ce7 --- /dev/null +++ b/sll/.editorconfig @@ -0,0 +1,17 @@ +# Editor configuration, see http://editorconfig.org +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 80 + +[*.sh] +end_of_line = lf + +[*.java] +indent_size = 4 +max_line_length = 120 diff --git a/sll/.idea/.gitignore b/sll/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/sll/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/sll/.idea/compiler.xml b/sll/.idea/compiler.xml new file mode 100644 index 0000000..c6d6875 --- /dev/null +++ b/sll/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/sll/.idea/encodings.xml b/sll/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/sll/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/sll/.idea/jarRepositories.xml b/sll/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/sll/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/sll/.idea/misc.xml b/sll/.idea/misc.xml new file mode 100644 index 0000000..ea0b3a9 --- /dev/null +++ b/sll/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/sll/.vscode/settings.json b/sll/.vscode/settings.json new file mode 100644 index 0000000..6f9c740 --- /dev/null +++ b/sll/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "print.colourScheme": "Atom One" +} \ No newline at end of file diff --git a/sll/pom.xml b/sll/pom.xml new file mode 100644 index 0000000..474ba67 --- /dev/null +++ b/sll/pom.xml @@ -0,0 +1,173 @@ + + 4.0.0 + com.tabrizu.ds + sll + 1.0 + + 1.8 + 1.8 + UTF-8 + 5.6.0 + 3.0.0-M3 + 3.1.2 + 8.45.1 + 3.0.0-M5 + 0.8.4 + 3.0.0 + + 0% + 0% + 20 + 5 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + org.apache.maven.plugins + maven-enforcer-plugin + ${maven-enforcer-plugin.version} + + + + enforce + + + + + 3.6.3 + + + true + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven-checkstyle-plugin.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + com.github.ngeor + checkstyle-rules + 4.9.3 + + + + com/github/ngeor/checkstyle.xml + true + ${skipTests} + + + + checkstyle + validate + + check + + + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + pre-unit-test + + prepare-agent + + + + post-unit-test + test + + report + + + + check-unit-test + test + + check + + + ${project.build.directory}/jacoco.exec + + + BUNDLE + + + INSTRUCTION + COVEREDRATIO + ${jacoco.unit-tests.limit.instruction-ratio} + + + BRANCH + COVEREDRATIO + ${jacoco.unit-tests.limit.branch-ratio} + + + + + CLASS + + + COMPLEXITY + TOTALCOUNT + ${jacoco.unit-tests.limit.class-complexity} + + + + + METHOD + + + COMPLEXITY + TOTALCOUNT + ${jacoco.unit-tests.limit.method-complexity} + + + + + + + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + + diff --git a/sll/src/main/java/com/tabrizu/ds/App.java b/sll/src/main/java/com/tabrizu/ds/App.java new file mode 100644 index 0000000..67b74fd --- /dev/null +++ b/sll/src/main/java/com/tabrizu/ds/App.java @@ -0,0 +1,19 @@ +package com.tabrizu.ds; + +/** + * Hello world! + */ +public final class App { + private App() { + } + + /** + * Says hello to the world. + * @param args The arguments of the program. + */ + public static void main(String[] args) { + System.out.println("Hello World!"); + + SingleLinkedList myList = new SingleLinkedList(); + } +} diff --git a/sll/src/main/java/com/tabrizu/ds/ISingleLinkedList.java b/sll/src/main/java/com/tabrizu/ds/ISingleLinkedList.java new file mode 100644 index 0000000..5c08412 --- /dev/null +++ b/sll/src/main/java/com/tabrizu/ds/ISingleLinkedList.java @@ -0,0 +1,12 @@ +package com.tabrizu.ds; + + +public interface ISingleLinkedList { + public int size(); + public void addFirst(T value); + public void addLast(T value); + public T removeFirst(); + public T removeLast(); + public T getFirst(); + public T getLast(); +} diff --git a/sll/src/main/java/com/tabrizu/ds/SingleLinkedList.java b/sll/src/main/java/com/tabrizu/ds/SingleLinkedList.java new file mode 100644 index 0000000..9c8ebd3 --- /dev/null +++ b/sll/src/main/java/com/tabrizu/ds/SingleLinkedList.java @@ -0,0 +1,106 @@ +package com.tabrizu.ds; + +public class SingleLinkedList implements ISingleLinkedList { + + private class Node { + private T m_value; + private Node m_next; + + public Node(T value, Node next) { + m_value = value; + m_next = next; + } + + public T getValue() { + return m_value; + } + + public Node getNext() { + return m_next; + } + + public void setNext(Node next) { + m_next = next; + } + } + + private Node m_head; + private Node m_tail; + private int m_size; + + public SingleLinkedList() { + m_head = null; + m_tail = null; + m_size = 0; + } + + @Override + public int size() { + return m_size; + } + + @Override + public void addFirst(T value) { + m_head = new Node(value, m_head); + if (m_size == 0) { + m_tail = m_head; + } + m_size += 1; + } + + @Override + public void addLast(T value) { + if (m_size == 0) { + addFirst(value); + } + Node newNode = new Node(value, null); + m_tail.setNext(newNode); + m_tail = newNode; + m_size++; + + } + + @Override + public T removeFirst() { + if (m_size == 0) { + return null; + } + T lastHead = m_head.getValue(); + m_head = m_head.getNext(); + m_size--; + + return lastHead; + } + + @Override + public T removeLast() { + if (m_size == 0) { + return null; + } + T lastTail = m_tail.getValue(); + Node currentNode = m_head; + while (currentNode.getNext() != null){ + + currentNode = currentNode.getNext(); + + } + } + + @Override + public T getFirst() { + // TODO Auto-generated method stub + return null; + } + + @Override + public T getLast() { + // TODO Auto-generated method stub + return null; + } + + @Override + public String toString() { + + } + +} diff --git a/sll/src/test/java/com/tabrizu/ds/AppTest.java b/sll/src/test/java/com/tabrizu/ds/AppTest.java new file mode 100644 index 0000000..7f5302a --- /dev/null +++ b/sll/src/test/java/com/tabrizu/ds/AppTest.java @@ -0,0 +1,18 @@ +package com.tabrizu.ds; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Unit test for simple App. + */ +class AppTest { + /** + * Rigorous Test. + */ + @Test + void testApp() { + assertEquals(1, 1); + } +} diff --git a/sll/target/classes/com/tabrizu/ds/App.class b/sll/target/classes/com/tabrizu/ds/App.class new file mode 100644 index 0000000..ff261ab Binary files /dev/null and b/sll/target/classes/com/tabrizu/ds/App.class differ diff --git a/sll/target/classes/com/tabrizu/ds/ISingleLinkedList.class b/sll/target/classes/com/tabrizu/ds/ISingleLinkedList.class new file mode 100644 index 0000000..657b5ba Binary files /dev/null and b/sll/target/classes/com/tabrizu/ds/ISingleLinkedList.class differ diff --git a/sll/target/classes/com/tabrizu/ds/SingleLinkedList$Node.class b/sll/target/classes/com/tabrizu/ds/SingleLinkedList$Node.class new file mode 100644 index 0000000..6940ec4 Binary files /dev/null and b/sll/target/classes/com/tabrizu/ds/SingleLinkedList$Node.class differ diff --git a/sll/target/classes/com/tabrizu/ds/SingleLinkedList.class b/sll/target/classes/com/tabrizu/ds/SingleLinkedList.class new file mode 100644 index 0000000..fa86609 Binary files /dev/null and b/sll/target/classes/com/tabrizu/ds/SingleLinkedList.class differ diff --git a/sll/target/test-classes/com/tabrizu/ds/AppTest.class b/sll/target/test-classes/com/tabrizu/ds/AppTest.class new file mode 100644 index 0000000..b95efda Binary files /dev/null and b/sll/target/test-classes/com/tabrizu/ds/AppTest.class differ