Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Samodzielna część #28

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cf469b4
1. dodanie pliku gitignore
KacperJarosik Apr 8, 2024
4e59548
usuniecie .gitignore
KacperJarosik Apr 8, 2024
70f53f5
1. Dodanie pliku .gitignore
KacperJarosik Apr 8, 2024
61a49b6
2. Formatowanie kodu w klasie HanoiRhymer
KacperJarosik Apr 8, 2024
7289a82
3. Formatowanie plików: Uycie ctrl+alt+l na folderze /src/main/java
KacperJarosik Apr 8, 2024
93b6cab
4. Zmiana nazwy klasy DefaultCountingOutRhymer by bya z duej litery
KacperJarosik Apr 8, 2024
026df95
4. Zmiana nazw metod by byly z malej litery
KacperJarosik Apr 8, 2024
ab50caa
5. Poprawienie nazw pol klas na poprawne
KacperJarosik Apr 8, 2024
305bf41
Merge branch 'class-method-naming'
KacperJarosik Apr 8, 2024
ac99eb7
6-7) zastąpiono literaly stalymi
DisturbedCherry May 6, 2024
19eb9e8
8) dodano @Override przy metodzie countIn w HanoiRhymer
DisturbedCherry May 6, 2024
94662ef
Corrected changes for my boss uwu
DisturbedCherry May 6, 2024
d763bb0
Merge pull request #2 from KacperJarosik/constants
KacperJarosik May 11, 2024
871a537
Zastosowanie najmniejszej możliwej widocznści w atrybutach klas
KacperJarosik May 11, 2024
8216ae3
Wygenerowanie getter dla pola total
KacperJarosik May 11, 2024
025e67b
Dokonanie hermetyzacji
KacperJarosik May 11, 2024
96e6e76
usunięcie nie używanych setterów
KacperJarosik May 11, 2024
7330c3c
Merge pull request #3 from KacperJarosik/2_idnywidualnie
KacperJarosik May 27, 2024
d215248
13. Uporządkuj aplikację demo RhymersDemo
KacperJarosik May 27, 2024
acaace9
Dokonaj refaktoryzacji IntLinkedList, aby uwzgldnil Node jako prywatn…
KacperJarosik May 27, 2024
0e79b0f
15. zmiana reportRejected z prywatnej - testy działają po zmianie
KacperJarosik May 27, 2024
a81bffc
16.Dodanie testów dla klasy IntLinkedList
KacperJarosik May 27, 2024
ebee079
16.Dodanie importów wykorzystanych w IntLinkedListTest
KacperJarosik May 27, 2024
67c9447
17.Dodanie dokumentacji dla IntLinkedList
KacperJarosik May 27, 2024
40a4b1e
18. dodaj notkę „TODO:”
KacperJarosik May 27, 2024
a66f8e6
Merge branch 'docs'
KacperJarosik May 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Ignorowanie folderów i plików generowanych przez narzędzia i IDE
/bin/
/target/
/.idea/
*.iml

# Ignorowanie plików wygenerowanych przez systemy operacyjne
Thumbs.db
ehthumbs.db
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
41 changes: 41 additions & 0 deletions src/main/java/edu/kis/vh/nursery/DefaultCountingOutRhymer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package edu.kis.vh.nursery;

public class DefaultCountingOutRhymer {

private static final int NUMBERS_ARRAY_SIZE = 12;
private static final int TOTAL_INIT_SIZE = -1;
private static final int RETURN_VALUE = -1;
private int[] numbers = new int[NUMBERS_ARRAY_SIZE];
// TODO: Move getTotal() method below the total variable declaration for better readability
public int getTotal() {
return total;
}

private int total = TOTAL_INIT_SIZE;

public void countIn(int in) {
if (!isFull())
numbers[++total] = in;
}

public boolean callCheck() {
return total == TOTAL_INIT_SIZE;
}

public boolean isFull() {
return total == NUMBERS_ARRAY_SIZE + TOTAL_INIT_SIZE;
}

protected int peekaboo() {
if (callCheck())
return RETURN_VALUE;
return numbers[total];
}

public int countOut() {
if (callCheck())
return RETURN_VALUE;
return numbers[total--];
}

}
22 changes: 11 additions & 11 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package edu.kis.vh.nursery;

public class FIFORhymer extends defaultCountingOutRhymer {
public class FIFORhymer extends DefaultCountingOutRhymer {

private DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();

public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();

@Override
public int countOut() {
while (!callCheck())
temp.countIn(super.countOut());

temp.countIn(super.countOut());

int ret = temp.countOut();

while (!temp.callCheck())
countIn(temp.countOut());

countIn(temp.countOut());

return ret;
}
}
}
13 changes: 7 additions & 6 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package edu.kis.vh.nursery;

public class HanoiRhymer extends defaultCountingOutRhymer {
public class HanoiRhymer extends DefaultCountingOutRhymer {

int totalRejected = 0;
private int totalRejected = 0;

public int reportRejected() {
int reportRejected() {
return totalRejected;
}

@Override
public void countIn(int in) {
if (!callCheck() && in > peekaboo())
if (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
else
super.countIn(in);
}
}
34 changes: 0 additions & 34 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
package edu.kis.vh.nursery.factory;

import edu.kis.vh.nursery.defaultCountingOutRhymer;
import edu.kis.vh.nursery.DefaultCountingOutRhymer;
import edu.kis.vh.nursery.FIFORhymer;
import edu.kis.vh.nursery.HanoiRhymer;
import edu.kis.vh.nursery.factory.Rhymersfactory;

public class DefaultRhymersFactory implements Rhymersfactory {

@Override
public defaultCountingOutRhymer GetStandardRhymer() {
return new defaultCountingOutRhymer();
public DefaultCountingOutRhymer getStandardRhymer() {
return new DefaultCountingOutRhymer();
}

@Override
public defaultCountingOutRhymer GetFalseRhymer() {
return new defaultCountingOutRhymer();
public DefaultCountingOutRhymer getFalseRhymer() {
return new DefaultCountingOutRhymer();
}

@Override
public defaultCountingOutRhymer GetFIFORhymer() {
public DefaultCountingOutRhymer getFIFORhymer() {
return new FIFORhymer();
}

@Override
public defaultCountingOutRhymer GetHanoiRhymer() {
public DefaultCountingOutRhymer getHanoiRhymer() {
return new HanoiRhymer();
}

Expand Down
26 changes: 13 additions & 13 deletions src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package edu.kis.vh.nursery.factory;

import edu.kis.vh.nursery.defaultCountingOutRhymer;

public interface Rhymersfactory {
public defaultCountingOutRhymer GetStandardRhymer();
public defaultCountingOutRhymer GetFalseRhymer();
public defaultCountingOutRhymer GetFIFORhymer();
public defaultCountingOutRhymer GetHanoiRhymer();
}
import edu.kis.vh.nursery.DefaultCountingOutRhymer;

public interface Rhymersfactory {

public DefaultCountingOutRhymer getStandardRhymer();

public DefaultCountingOutRhymer getFalseRhymer();

public DefaultCountingOutRhymer getFIFORhymer();

public DefaultCountingOutRhymer getHanoiRhymer();

}
85 changes: 81 additions & 4 deletions src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
package edu.kis.vh.nursery.list;

/**
* The IntLinkedList class represents a doubly linked list of integers.
* It supports basic operations such as push, pop, and checking if the list is empty or full.
*/
public class IntLinkedList {

Node last;
int i;
/**
* The constant value returned when an operation fails.
*/
public static final int returnValue = -1;

/**
* The last node in the linked list.
*/
private Node last;

/**
* An integer used for various purposes (currently unused).
*/

// TODO: Remove unused variable 'i' if it's not needed in the future
private int i;

/**
* Pushes a new integer onto the top of the linked list.
* If the list is empty, creates a new node as the last element.
* Otherwise, adds the new node to the end of the list.
*
* @param i the integer to be added to the list
*/
public void push(int i) {
if (last == null)
last = new Node(i);
Expand All @@ -15,26 +40,78 @@ public void push(int i) {
}
}

/**
* Checks if the linked list is empty.
*
* @return true if the list is empty, false otherwise
*/
public boolean isEmpty() {
return last == null;
}

/**
* Checks if the linked list is full.
* This implementation always returns false since the list is dynamically sized.
*
* @return false always, as the list cannot be full
*/
public boolean isFull() {
return false;
}

/**
* Returns the value of the last element in the list without removing it.
* If the list is empty, returns returnValue.
*
* @return the value of the last element, or returnValue if the list is empty
*/
public int top() {
if (isEmpty())
return -1;
return returnValue;
return last.value;
}

/**
* Removes and returns the value of the last element in the list.
* If the list is empty, returns returnValue.
*
* @return the value of the last element, or returnValue if the list is empty
*/
public int pop() {
if (isEmpty())
return -1;
return returnValue;
int ret = last.value;
last = last.prev;
return ret;
}

/**
* The Node class represents a node in a doubly linked list.
*/
private class Node {
/**
* The value stored in the node.
*/
private int value;

/**
* A reference to the previous node in the list.
*/
private Node prev;

/**
* A reference to the next node in the list.
*/
private Node next;

/**
* Creates a new node with the specified value.
*
* @param i the value to be stored in the node
*/
private Node(int i) {
value = i;
}
}

}
Loading