Skip to content
Open
27 changes: 27 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
61 changes: 61 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project
/target/
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/pio_git_rhymers_23.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>powp-rhymers</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
39 changes: 39 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,39 @@
package edu.kis.vh.nursery;

public class DefaultCountingOutRhymer {

public static final int NUMBER = 12;
public static final int NEGATIVE = -1;
private int[] numbers = new int[NUMBER];

private int total = NEGATIVE;

public int getTotal() {
return total;
}

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

public boolean isEmpty() {
return total == NEGATIVE;
}

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

protected int peekaboo() {
if (isEmpty())
return NEGATIVE;
return numbers[total];
}

public int countOut() {
if (isEmpty())
return NEGATIVE;
return numbers[total--];
}
}
21 changes: 0 additions & 21 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java

This file was deleted.

21 changes: 21 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,21 @@
package edu.kis.vh.nursery;

public class FifoRhymer extends DefaultCountingOutRhymer {

private DefaultCountingOutRhymer internalRhymer = new DefaultCountingOutRhymer();

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

internalRhymer.countIn(super.countOut());

int ret = internalRhymer.countOut();

while (!internalRhymer.isEmpty())

countIn(internalRhymer.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() {
return totalRejected;
}

@Override
public void countIn(int in) {
if (!callCheck() && in > peekaboo())
if (!isEmpty() && 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,29 @@
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.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() {
return new FIFORhymer();
public DefaultCountingOutRhymer GetFIFORhymer() {
return new FifoRhymer();
}

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

Expand Down
10 changes: 5 additions & 5 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;
import edu.kis.vh.nursery.DefaultCountingOutRhymer;

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

}
6 changes: 3 additions & 3 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package edu.kis.vh.nursery;

import edu.kis.vh.nursery.defaultCountingOutRhymer;
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;
Expand All @@ -10,7 +10,7 @@ class RhymersDemo {
public static void main(String[] args) {
Rhymersfactory factory = new DefaultRhymersFactory();

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

for (int i = 1; i < 15; i++)
Expand All @@ -22,7 +22,7 @@ public static void main(String[] args) {
rhymers[3].countIn(rn.nextInt(20));

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