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

Docs #55

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Empty file added .gitignore
Empty file.
Empty file.
10 changes: 5 additions & 5 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

public class FIFORhymer extends defaultCountingOutRhymer {

public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();
public defaultCountingOutRhymer tempRhymer = new defaultCountingOutRhymer();

@Override
public int countOut() {
while (!callCheck())

temp.countIn(super.countOut());
tempRhymer.countIn(super.countOut());

int ret = temp.countOut();
int ret = tempRhymer.countOut();

while (!temp.callCheck())
while (!tempRhymer.callCheck())a

countIn(temp.countOut());
countIn(tempRhymer.countOut());

return ret;
}
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

public class HanoiRhymer extends defaultCountingOutRhymer {

int totalRejected = 0;
private int rejectedCount = 0;

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

public void countIn(int in) {
if (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
if (!callCheck() && in > peekaboo())
rejectedCount++;
else
super.countIn(in);
}
}
43 changes: 21 additions & 22 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@

public class defaultCountingOutRhymer {

private int[] NUMBERS = new int[12];
private int[] numbers = new int[12];

public int total = -1;
private int total = -1;

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

public boolean callCheck() {
return total == -1;
}

public boolean isFull() {
return total == 11;
}

protected int peekaboo() {
if (callCheck())
return -1;
return NUMBERS[total];
}

public int countOut() {
if (callCheck())
return -1;
return NUMBERS[total--];
}
public boolean callCheck() {
return total == -1;
}

public boolean isFull() {
return total == 11;
}

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

public int countOut() {
if (callCheck())
return -1;
return numbers[total--];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
public class DefaultRhymersFactory implements Rhymersfactory {

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

@Override
public defaultCountingOutRhymer GetFalseRhymer() {
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
8 changes: 4 additions & 4 deletions src/main/java/edu/kis/vh/nursery/factory/Rhymersfactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

public interface Rhymersfactory {

public defaultCountingOutRhymer GetStandardRhymer();
public defaultCountingOutRhymer getStandardRhymer();

public defaultCountingOutRhymer GetFalseRhymer();
public defaultCountingOutRhymer getFalseRhymer();

public defaultCountingOutRhymer GetFIFORhymer();
public defaultCountingOutRhymer getFIFORhymer();

public defaultCountingOutRhymer GetHanoiRhymer();
public defaultCountingOutRhymer getHanoiRhymer();

}
7 changes: 5 additions & 2 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@
import edu.kis.vh.nursery.factory.DefaultRhymersFactory;
import edu.kis.vh.nursery.factory.Rhymersfactory;

//wygenerowano szkielet dokumentacji
class RhymersDemo {

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

public static void testRhymers(Rhymersfactory factory) {
defaultCountingOutRhymer[] rhymers = { factory.GetStandardRhymer(), factory.GetFalseRhymer(),
factory.GetFIFORhymer(), factory.GetHanoiRhymer()};

for (int i = 1; i < 15; i++)
for (int j = 0; j < 3; j++)
rhymers[j].countIn(i);
Expand Down