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

Merge branch ''format' to 'master' #13

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.class
.vscode/
.code-workspace
eclipse-formatter.xml
315 changes: 315 additions & 0 deletions eclipse-formatter.xml

Large diffs are not rendered by default.

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

/*

This is a sample comment, so I can check if Git pushing is
working properly. TODO Remove this comment */

public class FIFORhymer extends 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;
}
}
8 changes: 4 additions & 4 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;
int totalRejected = 0;

public int reportRejected() {
return totalRejected;
}

public void countIn(int in) {
if (!callCheck() && in > peekaboo())
if (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
else
super.countIn(in);
}
}
38 changes: 19 additions & 19 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ public void countIn(int 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 @@ -3,9 +3,8 @@
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 {
public class DefaultRhymersFactory implements RhymersFactory {

@Override
public defaultCountingOutRhymer GetStandardRhymer() {
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 GetFIFORhymer();

public defaultCountingOutRhymer GetHanoiRhymer();

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

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/edu/kis/vh/nursery/list/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public class Node {
public Node(int i) {
value = i;
}

}
22 changes: 10 additions & 12 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
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();
RhymersFactory factory = new DefaultRhymersFactory();

defaultCountingOutRhymer[] rhymers = { factory.GetStandardRhymer(), factory.GetFalseRhymer(),
factory.GetFIFORhymer(), factory.GetHanoiRhymer()};
factory.GetFIFORhymer(), 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());

}

}