Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
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
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@

# Created by https://www.toptal.com/developers/gitignore/api/vscode,java
# Edit at https://www.toptal.com/developers/gitignore?templates=vscode,java

### Java ###
# Compiled class file
*.class

.classpath
.project

# 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*

### vscode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# End of https://www.toptal.com/developers/gitignore/api/vscode,java
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
2 changes: 2 additions & 0 deletions .settings/org.eclipse.jdt.apt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
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.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions .settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ na wydziale Elektrotechniki, Elektroniki Informatyki i Automatyki Politechniki

## materiały i dodatkowe informacje


## ogólne zasady oceny pracy na laboratoriach

- [WIKI projektu z opisem zadań oraz sposobu współpracy studentów w ich realizacji](https://github.com/iis-io-team/pio_git_rhymers/wiki)
16 changes: 16 additions & 0 deletions powp-rhymers.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
</component>
</module>
38 changes: 38 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,38 @@
package edu.kis.vh.nursery;

import edu.kis.vh.nursery.containers.Container;
import edu.kis.vh.nursery.containers.IntArrayStack;
import edu.kis.vh.nursery.containers.IntLinkedList;

public class DefaultCountingOutRhymer {

// private Container container = new IntArrayStack();
private Container container = new IntLinkedList();

public DefaultCountingOutRhymer(){}

public void countIn(final int in) {
container.push(in);
}

public boolean callCheck() {
return container.isEmpty();
}

public boolean isFull() {
return container.isFull();
}

protected int peekaboo() {
return container.peekaboo();
}

public int countOut() {
return container.pop();
}

public DefaultCountingOutRhymer(IntArrayStack intArrayStack){
this.container = intArrayStack;
}

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

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

public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();

private final DefaultCountingOutRhymer temp = new DefaultCountingOutRhymer();

// final public defaultCountingOutRhymer temp = new defaultCountingOutRhymer();
/**
* @param none
* @return int
*/
@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;
}
}
13 changes: 8 additions & 5 deletions src/main/java/edu/kis/vh/nursery/HanoiRhymer.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
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 (!callCheck() && in > peekaboo())
totalRejected++;
else
super.countIn(in);
else
super.countIn(in);
}
}
// alt + strzałka w VSCode przełącza między ostatnio otwieranymi plikami w
// projekcie
15 changes: 15 additions & 0 deletions src/main/java/edu/kis/vh/nursery/containers/Container.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.kis.vh.nursery.containers;

public interface Container {
public int pop();

public void push(int value);

public int peekaboo();

public int size();

public boolean isEmpty();

public boolean isFull();
}
44 changes: 44 additions & 0 deletions src/main/java/edu/kis/vh/nursery/containers/IntArrayStack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package edu.kis.vh.nursery.containers;

public class IntArrayStack implements Container {
public static final int DEFAULT_VALUE = -1;
public static final int MAX_SIZE = 12;
public static final int EMPTY_RHYMER_INDICATOR = -1;

final private int[] numbers = new int[MAX_SIZE];
public int CURRENT_TOTAL_NUMBERS = EMPTY_RHYMER_INDICATOR;

@Override
public void push(final int in) {
if (!isFull())
numbers[++CURRENT_TOTAL_NUMBERS] = in;
}

@Override
public boolean isEmpty() {
return CURRENT_TOTAL_NUMBERS == EMPTY_RHYMER_INDICATOR;
}

@Override
public boolean isFull() {
return CURRENT_TOTAL_NUMBERS == 11;
}

public int peekaboo() {
if (isEmpty())
return EMPTY_RHYMER_INDICATOR;
return numbers[CURRENT_TOTAL_NUMBERS];
}

@Override
public int pop() {
if (isEmpty())
return EMPTY_RHYMER_INDICATOR;
return numbers[CURRENT_TOTAL_NUMBERS--];
}

@Override
public int size() {
return CURRENT_TOTAL_NUMBERS + 1;
}
}
59 changes: 59 additions & 0 deletions src/main/java/edu/kis/vh/nursery/containers/IntLinkedList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package edu.kis.vh.nursery.containers;

public class IntLinkedList implements Container {

public static final int DEFAULT_VALUE = -1;
Node last;
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;
}
}

public boolean isEmpty() {
return last == null;
}

public boolean isFull() {
return false;
}

public int peekaboo() {
if (isEmpty())
return DEFAULT_VALUE;
return last.getValue();
}

public int pop() {
if (isEmpty())
return DEFAULT_VALUE;
int ret = last.getValue();
last = last.prev;
return ret;
}

@Override
public int size() {
int size = 0;
Node current = last;
while (true) {
if (current.prev == null)
break;
current = current.prev;
}
while (true) {
if (current.next == null)
break;
current = current.next;
size++;
}
return size;
}

}
16 changes: 16 additions & 0 deletions src/main/java/edu/kis/vh/nursery/containers/Node.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package edu.kis.vh.nursery.containers;

public class Node {

final private int value;
public Node prev, next;

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

public int getValue(){
return value;
}

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

This file was deleted.

Loading