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

Accessory i hermetyzacja #65

Open
wants to merge 27 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7003bd7
„1. dodanie pliku gitignore
245965 May 9, 2024
f20ee97
2.Formatowanie kodu
245965 May 12, 2024
abc93e7
2.Formatowanie kodu dalej
245965 May 12, 2024
34c9bbb
2.Formatowanie kodu
245965 May 12, 2024
b61844c
2. Formatowanie
245965 May 12, 2024
a2d30c0
2.Formatowanie
245965 May 12, 2024
086165d
2.Formatowanie
245965 May 12, 2024
b3f75e9
2.Formatowanie
245965 May 12, 2024
fc5444d
2.Formatowanie
245965 May 12, 2024
109be1a
2.Formatowanie
245965 May 12, 2024
2164aa3
2.Formatowanie
245965 May 12, 2024
1feb03f
2.Formatowanie
245965 May 12, 2024
d4c5654
2.Formatowanie
245965 May 12, 2024
2bdb3fe
3.Scalanie zmian z gałęzi format
245965 May 12, 2024
3fe5ebf
3. Formatowanie kodu
245965 May 12, 2024
64c6291
5.Poprawa nazewnictwa pól klas
245965 May 12, 2024
92bdaba
4.1 poprawa nazw klas
245965 May 12, 2024
5210d1d
4.2 zmiana konwencji nazewniczej metod
245965 May 12, 2024
0a665dd
Merge branch 'class-method-naming'
245965 May 12, 2024
08591e0
6. Deklaracja stałych
michalstr245931 May 19, 2024
635b240
7. Ustawienie modyfikatora final przy atrybutach klas
michalstr245931 May 19, 2024
fd0bc64
8. Użycie annotacji @Override przy metodzie countIn()
michalstr245931 May 19, 2024
aef2235
Merge pull request #2 from 245965/constants
245965 May 27, 2024
3bffbb2
9.Analiza widoczności modyfikatorów
245965 May 27, 2024
03c3aac
10.Generacja gettera i settera
245965 May 27, 2024
15ff72a
11. Dokonanie hermetyzacji nieprywatnych atrybutów
245965 May 31, 2024
0a82094
12. Usunięcie nieużywanych setterów
245965 May 31, 2024
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
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Compiled class file
#*.class
#
## Log file
#*.log
#
## BlueJ files
#*.ctxt
#
## Mobile Tools for Java (J2ME)
#.mtj.tmp/
#
## Package Files #
#*.jar
#*.war
#*.nar
#*.ear
#*.zip
#*.tar.gz
#*.rar
#
## virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
#hs_err_pid*
#replay_pid*


/.idea/
/.target/
Empty file added git
Empty file.
43 changes: 43 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,43 @@
package edu.kis.vh.nursery;

public class DefaultCountingOutRhymer {

private static final int CAPACITY = 12;
private static final int EMPTY = -1;

private final int[] numbers = new int[CAPACITY];

public int getTotal() {
return total;
}



private int total = EMPTY;

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

public boolean callCheck() {
return total == EMPTY;
}

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

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

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

}
21 changes: 0 additions & 21 deletions src/main/java/edu/kis/vh/nursery/FIFORhymer.java

This file was deleted.

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

public class FifoRhymer extends DefaultCountingOutRhymer {

private final DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();

@Override
public int countOut() {
while (!callCheck())
getTemp().countIn(super.countOut());

int ret = getTemp().countOut();

while (!getTemp().callCheck())
countIn(getTemp().countOut());

return ret;
}

public DefaultCountingOutRhymer getTemp() {
return temp;
}
}
23 changes: 16 additions & 7 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
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;
return getTotalRejected();
}

@Override
public void countIn(int in) {
if (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
if (!callCheck() && in > peekaboo())
setTotalRejected(getTotalRejected() + 1);
else
super.countIn(in);
}

public int getTotalRejected() {
return totalRejected;
}

public void setTotalRejected(int totalRejected) {
this.totalRejected = totalRejected;
}
}
34 changes: 0 additions & 34 deletions src/main/java/edu/kis/vh/nursery/defaultCountingOutRhymer.java

This file was deleted.

21 changes: 10 additions & 11 deletions src/main/java/edu/kis/vh/nursery/factory/DefaultRhymersFactory.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
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 {
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
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.

5 changes: 3 additions & 2 deletions src/main/java/edu/kis/vh/nursery/list/IntLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class IntLinkedList {

public static final int EMPTY = -1;
Node last;
int i;

Expand All @@ -25,13 +26,13 @@ public boolean isFull() {

public int top() {
if (isEmpty())
return -1;
return EMPTY;
return last.value;
}

public int pop() {
if (isEmpty())
return -1;
return EMPTY;
int ret = last.value;
last = last.prev;
return ret;
Expand Down
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;
}

}
10 changes: 4 additions & 6 deletions src/test/java/edu/kis/vh/nursery/RhymersDemo.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
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()};
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import org.junit.Assert;
import org.junit.Test;

public class RhymersJUnitTest {
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
Binary file added target/classes/edu/kis/vh/nursery/FIFORhymer.class
Binary file not shown.
Binary file added target/classes/edu/kis/vh/nursery/HanoiRhymer.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added target/classes/edu/kis/vh/nursery/list/Node.class
Binary file not shown.
Binary file not shown.
Binary file not shown.