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

Mergowanie brancha docs z master #72

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
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
47e01f2
1. Dodanie pliku gitignore.
SebastianCieslik245787 May 12, 2024
7996fb3
2. Poprawienie formatowania kodu w pliku HanoiRhymer.
SebastianCieslik245787 May 12, 2024
a874b5a
3. Scalenie gałęzi master z gałęziom format
SebastianCieslik245787 May 12, 2024
4336d8b
4.1. Poprawienie nazw class.
SebastianCieslik245787 May 12, 2024
c3e48a0
4.2. Poprawienie nazw metod.
SebastianCieslik245787 May 12, 2024
245c7b5
5. Poprawa nazw zmiennych.
SebastianCieslik245787 May 12, 2024
adc772b
5. Scalenie gałęzi class-method-naming i gałęzi master
SebastianCieslik245787 May 12, 2024
a52aef7
6. Zastąpienie literałów stałymi
SzymonGieraga May 13, 2024
d645036
6.1 Zastąpienie literałów stałymi
SzymonGieraga May 13, 2024
7b114f1
7. Dodanie modyfikatora final do stałych niemutowalnych
SzymonGieraga May 13, 2024
34c3442
8. Dodanie @Override w metodzie klasy HanoiRhymer.java
SzymonGieraga May 13, 2024
79d62ae
6.2 Zastąpienie literałów stałymi w pliku DefaultCountingOutrhymer.java
SzymonGieraga May 20, 2024
a0350b8
7.1 Dodanie modyfikatora final do stałych niemutowalnych w plikach No…
SzymonGieraga May 20, 2024
f731223
6.3 Poprawienie definicji stałych w pliku DefaultCountingOutRhymer.java
SzymonGieraga May 24, 2024
16a7684
6.4 Dodanie stałych w pliku IntLinkedList.java
SzymonGieraga May 24, 2024
d4bc66e
Merge pull request #2 from SebastianCieslik245787/constants
SebastianCieslik245787 May 27, 2024
f0e26b4
9. Zmiana atrybutów klas
SebastianCieslik245787 May 27, 2024
b2437ad
10. Wygenerowanie gettera dla total w klasie DefaultCountingOutRhymer
SebastianCieslik245787 May 27, 2024
c350d50
11. Hermetyzacja publicznych atrymutów klasy Node
SebastianCieslik245787 May 27, 2024
9d85ef1
Merge pull request #3 from SebastianCieslik245787/Accessory-i-hermety…
SebastianCieslik245787 May 27, 2024
58c5960
13. Utworzenie metody testRhymers.
SebastianCieslik245787 Jun 3, 2024
947829e
14. Przeniesienie klasy Node do IntLinkedList oraz zmiana z publiczne…
SebastianCieslik245787 Jun 3, 2024
3809e23
17. Stworzenie dokumentacji dla klasy DefaultCountingOutRhymer.
SebastianCieslik245787 Jun 3, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.idea/
/target/
/bin/
60 changes: 60 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,60 @@
package edu.kis.vh.nursery;
/*
The DefaultCountingOutRhymer class is used to count out rhymers.
*/
public class DefaultCountingOutRhymer {
private static final int EMPTY = -1;
private final int MAX_SIZE = 12;
private final int FULL = MAX_SIZE - 1;

private static final int DEFAULT = -1;


private final int[] numbers = new int[MAX_SIZE];
/*
getTotal method returns value of elements in array numbers.
variable total is a number of rhymers in array.
*/
public int getTotal() {
return total;
}

private int total = EMPTY;
/*
countIn method inserts value into numbers array after the last element, if array isn't full.
argument in is a value that will be inserted into array as the next element.
*/
public void countIn(int in) {
if (!isFull())
numbers[++total] = in;
}
/*
callCheck is a method that returns true, if array number is empty, otherwise returns false.
*/
public boolean callCheck() {
return total == DEFAULT;
}
/*
isFull is a method that returns true, if array number is full.
*/
public boolean isFull() {
return total == FULL;
}
/*
peekaboo is a method that returns value of the last inserted element into number's array, if array isn't empty, otherwise returns DEFAULT value.
*/
protected int peekaboo() {
if (callCheck())
return DEFAULT;
return numbers[total];
}
/*
countOut method is returning last inserted elements and reduce last element, if array numbers isn't empty, otherwise returns EMPTY value.
*/
public int countOut() {
if (callCheck())
return EMPTY;
return numbers[total--];
}

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

This file was deleted.

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

public class FirstInFirstOutRhymer extends DefaultCountingOutRhymer {

private final DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();

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

int ret = temp.countOut();

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

return ret;
}
}
11 changes: 6 additions & 5 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() {
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.

21 changes: 10 additions & 11 deletions src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java
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.DefaultCountingOutRhymer;
import edu.kis.vh.nursery.FirstInFirstOutRhymer;
import edu.kis.vh.nursery.HanoiRhymer;
import edu.kis.vh.nursery.factory.Rhymersfactory;

public class DefaultRhymersFactory implements 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() {
return new FIFORhymer();
public DefaultCountingOutRhymer getFirtsInFirstOutRhymer() {
return new FirstInFirstOutRhymer();
}

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

Expand Down
15 changes: 15 additions & 0 deletions src/main/java/edu/kis/vh/nursery/factory/RhymersFactory.java
Original file line number Diff line number Diff line change
@@ -0,0 +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 getFirtsInFirstOutRhymer();

public DefaultCountingOutRhymer getHanoiRhymer();

}
15 changes: 0 additions & 15 deletions src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java

This file was deleted.

50 changes: 40 additions & 10 deletions src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

public class IntLinkedList {

Node last;
int i;
private static final int EMPTY_LIST = -1;
private Node last;
private int i;

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();
}
}

Expand All @@ -25,16 +26,45 @@ public boolean isFull() {

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

public int pop() {
if (isEmpty())
return -1;
int ret = last.value;
last = last.prev;
return EMPTY_LIST;
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;
}
}
}
12 changes: 0 additions & 12 deletions src/main/java/edu/kis/vh/nursery/list/Node.java

This file was deleted.

23 changes: 8 additions & 15 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
package edu.kis.vh.nursery;

import edu.kis.vh.nursery.defaultCountingOutRhymer;
import edu.kis.vh.nursery.HanoiRhymer;
import edu.kis.vh.nursery.factory.DefaultRhymersFactory;
import edu.kis.vh.nursery.factory.Rhymersfactory;
import edu.kis.vh.nursery.factory.RhymersFactory;

class RhymersDemo {

public static void main(String[] args) {
Rhymersfactory factory = new DefaultRhymersFactory();

defaultCountingOutRhymer[] rhymers = { factory.GetStandardRhymer(), factory.GetFalseRhymer(),
factory.GetFIFORhymer(), factory.GetHanoiRhymer()};

RhymersFactory factory = new DefaultRhymersFactory();
testRhymers(factory);
}

private static void testRhymers(RhymersFactory factory) {
DefaultCountingOutRhymer[] rhymers = {factory.getStandardRhymer(), factory.getFalseRhymer(), factory.getFirtsInFirstOutRhymer(), factory.getHanoiRhymer()};
for (int i = 1; i < 15; i++)
for (int j = 0; j < 3; j++)
rhymers[j].countIn(i);

java.util.Random rn = new java.util.Random();
for (int i = 1; i < 15; i++)
rhymers[3].countIn(rn.nextInt(20));

for (int i = 0; i < rhymers.length; i++) {
while (!rhymers[i].callCheck())
System.out.print(rhymers[i].countOut() + " ");
System.out.println();
}

System.out.println("total rejected is "
+ ((HanoiRhymer) rhymers[3]).reportRejected());

System.out.println("total rejected is " + ((HanoiRhymer) rhymers[3]).reportRejected());
}

}
Loading