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

Class method naming #89

Open
wants to merge 18 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea/
target/
bin/
26 changes: 13 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,21 @@
package edu.kis.vh.nursery;

public class FIFORhymer extends defaultCountingOutRhymer {
public class FIFORhymer extends DefaultCountingOutRhymer {

private final DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();

public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();

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

temp.countIn(super.countOut());
protected int countOut() {
while (!callCheck()) {
temp.countIn(super.countOut());
}

int ret = temp.countOut();
while (!temp.callCheck())

countIn(temp.countOut());

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

return ret;
}
}
17 changes: 9 additions & 8 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;
int totalRejected = 0;

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

public void countIn(int in) {
if (!callCheck() && in > peekaboo())
@Override
protected void countIn(int in) {
if (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
}
else
super.countIn(in);
}
}
28 changes: 18 additions & 10 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
package edu.kis.vh.nursery;

public class defaultCountingOutRhymer {
public class DefaultCountingOutRhymer {

private int[] NUMBERS = new int[12];
private static final int minusOne = -1;
private static final int eleven = 11;
private static final int numLength = 12;
private int[] NUMBERS = new int[numLength];

public int total = -1;
public int getTotal() {
return total;
}


public int total = minusOne;

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

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

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

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

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

Expand Down
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;

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

}
16 changes: 8 additions & 8 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,16 @@

public class IntLinkedList {

Node last;
int i;
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 @@ -26,14 +26,14 @@ public boolean isFull() {
public int top() {
if (isEmpty())
return -1;
return last.value;
return last.getValue();
}

public int pop() {
if (isEmpty())
return -1;
int ret = last.value;
last = last.prev;
int ret = last.getValue();
last = last.getPrev();
return ret;
}

Expand Down
31 changes: 28 additions & 3 deletions src/main/java/edu/kis/vh/nursery/list/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,36 @@

public class Node {

public int value;
public Node prev, next;


private int value;
private Node prev, next;

public Node(int i) {
value = i;
}

public int getValue() {
return value;
}

public Node getPrev() {
return prev;
}

public Node getNext() {
return next;
}

public void setValue(int value) {
this.value = value;
}

public void setPrev(Node prev) {
this.prev = prev;
}

public void setNext(Node next) {
this.next = next;
}
}