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

??? #38

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open

??? #38

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f308aae
1. dodanie pliku gitignore
Apr 8, 2024
f443f4d
2. Poprawa błędów formatowania w klasie HanoiRhymer
nbalicka35 Apr 8, 2024
c236f56
2. Poprawa błędów formatowania w klasie HanoiRhymer
nbalicka35 Apr 8, 2024
eab9af9
4.1 poprawa nazw klas
nbalicka35 Apr 13, 2024
8f0ba5d
4.2 zmiana nazewnictwa metod
nbalicka35 Apr 13, 2024
423476a
5. zmiana konwencji nazewniczej pól klas
nbalicka35 Apr 13, 2024
3ea2d21
4.2 zmiana nazewnictwa metod
nbalicka35 Apr 13, 2024
1bc6fa8
Merge branch 'master' into class-method-naming
nbalicka35 Apr 13, 2024
afdf03c
Merge branch 'class-method-naming'
nbalicka35 Apr 13, 2024
34ad9f5
5. merge class-method-naming do galezi master
nbalicka35 Apr 13, 2024
51d4cdb
5. merge
nbalicka35 Apr 13, 2024
cece72a
9. Zastosowanie najmniejszej widocznosci
nbalicka35 May 19, 2024
653cd2d
10. Wygenerowanie gettera dla pola total w klasie DefaultCountingOutR…
nbalicka35 May 19, 2024
1293efe
11. Hermetyzacja nieprywatnych atrybutow
nbalicka35 May 19, 2024
cb99f3d
12. Usuniecie nieuzywanych setterow
nbalicka35 May 19, 2024
5af96a1
Merge pull request #2 from nbalicka35/Accessory_i_hermetyzacja
nbalicka35 May 19, 2024
ca1df4d
13. Rozbicie metody main
nbalicka35 Jun 2, 2024
7c6bf60
14. Zmiana klasy Node na prywatna
nbalicka35 Jun 2, 2024
a954ed1
15. Uruchomienie testow jednostkowych, wszystkie zakonczone sukcesem
nbalicka35 Jun 2, 2024
f337598
16. Testy jednostkowe do LinkedList i uruchomienie
nbalicka35 Jun 2, 2024
2236e9b
17. wykonanie dokumentacji dla defaultRhymer
nbalicka35 Jun 2, 2024
f640759
18. Notatki TODO oraz zmiana nazw funkcji
nbalicka35 Jun 2, 2024
6b545d4
Merge pull request #3 from nbalicka35/docs
nbalicka35 Jun 2, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependency>
</dependencies>
</project>
21 changes: 0 additions & 21 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java

This file was deleted.

25 changes: 25 additions & 0 deletions src/main/java/edu/kis/vh/nursery/FIFOrhymer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package edu.kis.vh.nursery;

public class FIFOrhymer extends defaultRhymer {

private final defaultRhymer temp = new defaultRhymer();

@Override
protected int getPenultimateNumber() {
while (!check())

temp.countIn(super.getPenultimateNumber());

int ret = temp.getPenultimateNumber();

while (!temp.check())

countIn(temp.getPenultimateNumber());

return ret;
}

public defaultRhymer getTemp() {
return temp;
}
}
20 changes: 13 additions & 7 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package edu.kis.vh.nursery;

public class HanoiRhymer extends defaultCountingOutRhymer {
public class HanoiRhymer extends defaultRhymer {

int totalRejected = 0;
private int totalRejected = 0;

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

public void countIn(int in) {
if (!callCheck() && in > peekaboo())
protected void countIn(int in) {
if (!check() && in > getLastNumber())
totalRejected++;
else
super.countIn(in);
else
super.countIn(in);
}

public int getTotalRejected() {
return totalRejected;
}


}
34 changes: 0 additions & 34 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java

This file was deleted.

69 changes: 69 additions & 0 deletions src/main/java/edu/kis/vh/nursery/defaultRhymer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package edu.kis.vh.nursery;

public class defaultRhymer {

private final int[] NUMBERS = new int[12];
private final int STACK_IS_EMPTY = -1;
private int total = -1;

public int getTotal() {
return total;
}
/**
* Adds a number to the stack if it is not full.
*
* @param in - number to be added
*/
protected void countIn(int in) {
if (!isFull())
NUMBERS[++total] = in;
}
/**
* Checks if the stack is empty.
*
* @return true if the stack is empty, false if it's not
*/
protected boolean check() {
return total == -1;
}


/**
* Checks if the stack is full.
*
* @return true if the stack is full, false if it's not
*/
protected boolean isFull() {
return total == 11;
}
/**
* Returns top value of the stack.
*
* @return value at the top of stack - if stack is empty returns STACK_IS_EMPTY
*/
protected int getLastNumber() {
if (check())
return STACK_IS_EMPTY;
return NUMBERS[total];
}
/**
* Removes and returns the value at the top of the stack.
*
* @return value at the top of stack - if stack is empty returns STACK_IS_EMPTY
*/
protected int getPenultimateNumber() {
if (check())
return STACK_IS_EMPTY;
return NUMBERS[total--];
}
/**
* Returns the current stack.
*
* @return current stack
*/
public int[] getNUMBERS() {
return NUMBERS;
}


}
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.FIFORhymer;
import edu.kis.vh.nursery.defaultRhymer;
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 defaultRhymer getStandardRhymer() {
return new defaultRhymer();
}

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

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

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

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

import edu.kis.vh.nursery.defaultCountingOutRhymer;
import edu.kis.vh.nursery.defaultRhymer;

public interface Rhymersfactory {

public defaultCountingOutRhymer GetStandardRhymer();

public defaultCountingOutRhymer GetFalseRhymer();

public defaultCountingOutRhymer GetFIFORhymer();

public defaultCountingOutRhymer GetHanoiRhymer();

public defaultRhymer getStandardRhymer();
// TODO: modifier 'public' needs to be deleted - redundant for interface members


public defaultRhymer getFalseRhymer();
// TODO: modifier 'public' needs to be deleted - redundant for interface members

public defaultRhymer getFIFORhymer();
// TODO: modifier 'public' needs to be deleted - redundant for interface members

public defaultRhymer getHanoiRhymer();
// TODO: modifier 'public' needs to be deleted - redundant for interface members

}
56 changes: 42 additions & 14 deletions src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,67 @@

public class IntLinkedList {

Node last;
int i;

private static final int EMPTY_VALUE = -1;
private Node last;
private int i;
// TODO: 'i' field needs to be deleted, it's never used
public void push(int i) {
if (last == null)
last = new Node(i);
else {
last.next = new Node(i);
last.next.prev = last;
last = last.next;
last.setNext(new Node(i));
last.getNext().setPrev(last);
last = last.getNext();
}
}

public boolean isEmpty() {
return last == null;
}

public boolean isFull() {
return false;
}
// TODO: method unused, needs proper implementation

public int top() {
if (isEmpty())
return -1;
return last.value;
return EMPTY_VALUE;
return last.getValue();
}

public int pop() {
if (isEmpty())
return -1;
int ret = last.value;
last = last.prev;
return EMPTY_VALUE;
int ret = last.getValue();
last = last.getPrev();
return ret;
}
private class Node {

private final int value;
private Node prev;
private Node next;

public Node(int i) {
value = i;
}

public int getValue() {
return value;
}

public Node getPrev() {
return prev;
}

public void setPrev(Node prev) {
this.prev = prev;
}

public Node getNext() {
return next;
}

public void setNext(Node next) {
this.next = next;
}
}
}
Loading