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

Constants #77

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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
40 changes: 40 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?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 excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="optional" 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 excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
<attribute name="optional" 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>
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Ignorowanie plików wygenerowanych przez IDE
.idea/
.vscode/

# Ignorowanie plików wykonywalnych
*.exe
*.dll

# Ignorowanie plików tymczasowych
*.tmp
*.bak

# Ignorowanie plików konfiguracyjnych, które mogą zawierać hasła
*.config

# Ignorowanie plików logów
*.log
/target/
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>pio_git_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>
3 changes: 3 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
8 changes: 8 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
7 changes: 7 additions & 0 deletions src/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="main/java"/>
<classpathentry kind="src" path="test/java"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
17 changes: 17 additions & 0 deletions src/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>src</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
19 changes: 6 additions & 13 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
package edu.kis.vh.nursery;

public class FIFORhymer extends defaultCountingOutRhymer {

public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();

public class FIFORhymer extends DefaultCountingOutRhymer {
public DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();
@Override
public int countOut() {
while (!callCheck())

temp.countIn(super.countOut());

int ret = temp.countOut();

while (!temp.callCheck())

countIn(temp.countOut());

temp.countIn(super.countOut());
int ret = temp.countOut();
while (!temp.callCheck())
countIn(temp.countOut());
return ret;
}
}
17 changes: 8 additions & 9 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package edu.kis.vh.nursery;

public class HanoiRhymer extends defaultCountingOutRhymer {

int totalRejected = 0;

public class HanoiRhymer extends DefaultCountingOutRhymer {
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);
}
}
}
46 changes: 24 additions & 22 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
package edu.kis.vh.nursery;

public class defaultCountingOutRhymer {
public class DefaultCountingOutRhymer {

private int[] NUMBERS = new int[12];
public static final int TOTAL_NUMBERS = 12;
public static final int EMPTY = -1;
public static final int MAX_CAPACITY = TOTAL_NUMBERS - 1;

private int[] NUMBERS = new int[TOTAL_NUMBERS];

public int total = -1;
public int total = EMPTY;

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

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

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

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

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

}
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.DefaultCountingOutRhymer;
import edu.kis.vh.nursery.FIFORhymer;
import edu.kis.vh.nursery.HanoiRhymer;
import edu.kis.vh.nursery.factory.Rhymersfactory;
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() {
public DefaultCountingOutRhymer getFIFORhymer() {
return new FIFORhymer();
}

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

Expand Down
12 changes: 6 additions & 6 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 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();

}
15 changes: 8 additions & 7 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
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;
import edu.kis.vh.nursery.factory.RhymersFactory;

/**
* Comment do clasu RhymersDemo
*/
class RhymersDemo {

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

defaultCountingOutRhymer[] rhymers = { factory.GetStandardRhymer(), factory.GetFalseRhymer(),
factory.GetFIFORhymer(), factory.GetHanoiRhymer()};
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++)
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/edu/kis/vh/nursery/RhymersJUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class RhymersJUnitTest {

@Test
public void testCountIn() {
defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer();
DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer();
int testValue = 4;
rhymer.countIn(testValue);

Expand All @@ -17,7 +17,7 @@ public void testCountIn() {

@Test
public void testCallCheck() {
defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer();
DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer();
boolean result = rhymer.callCheck();
Assert.assertEquals(true, result);

Expand All @@ -29,7 +29,7 @@ public void testCallCheck() {

@Test
public void testIsFull() {
defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer();
DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer();
final int STACK_CAPACITY = 12;
for (int i = 0; i < STACK_CAPACITY; i++) {
boolean result = rhymer.isFull();
Expand All @@ -43,7 +43,7 @@ public void testIsFull() {

@Test
public void testPeekaboo() {
defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer();
DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer();
final int EMPTY_STACK_VALUE = -1;

int result = rhymer.peekaboo();
Expand All @@ -60,7 +60,7 @@ public void testPeekaboo() {

@Test
public void testCountOut() {
defaultCountingOutRhymer rhymer = new defaultCountingOutRhymer();
DefaultCountingOutRhymer rhymer = new DefaultCountingOutRhymer();
final int EMPTY_STACK_VALUE = -1;

int result = rhymer.countOut();
Expand Down