Util cleaning
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
package netwerkprog.game.util.game;
|
package netwerkprog.game.util.game;
|
||||||
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||||
import netwerkprog.game.client.game.map.GameTile;
|
import netwerkprog.game.client.game.map.GameTile;
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ public class FrameRate implements Disposable{
|
|||||||
long lastTimeCounted;
|
long lastTimeCounted;
|
||||||
private float sinceChange;
|
private float sinceChange;
|
||||||
private float frameRate;
|
private float frameRate;
|
||||||
private BitmapFont font;
|
private final BitmapFont font;
|
||||||
private SpriteBatch batch;
|
private final SpriteBatch batch;
|
||||||
private OrthographicCamera cam;
|
private OrthographicCamera cam;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
|||||||
import com.badlogic.gdx.utils.Disposable;
|
import com.badlogic.gdx.utils.Disposable;
|
||||||
|
|
||||||
public class TextRenderer implements Disposable {
|
public class TextRenderer implements Disposable {
|
||||||
private BitmapFont font;
|
private final BitmapFont font;
|
||||||
private SpriteBatch batch;
|
private final SpriteBatch batch;
|
||||||
private OrthographicCamera cam;
|
private OrthographicCamera cam;
|
||||||
|
|
||||||
public TextRenderer() {
|
public TextRenderer() {
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
package netwerkprog.game.util.tree;
|
package netwerkprog.game.util.tree;
|
||||||
|
|
||||||
public abstract class AbstractTree<E> implements Tree<E> {
|
public abstract class AbstractTree<E> implements Tree<E> {
|
||||||
@Override /** Inorder traversal from the root*/
|
@Override /* Inorder traversal from the root*/
|
||||||
public void inorder() {
|
public void inorder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override /** Postorder traversal from the root */
|
@Override /* Postorder traversal from the root */
|
||||||
public void postorder() {
|
public void postorder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override /** Preorder traversal from the root */
|
@Override /* Preorder traversal from the root */
|
||||||
public void preorder() {
|
public void preorder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override /** Return true if the tree is empty */
|
@Override /* Return true if the tree is empty */
|
||||||
public boolean isEmpty() {
|
public boolean isEmpty() {
|
||||||
return getSize() == 0;
|
return getSize() == 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,13 @@
|
|||||||
package netwerkprog.game.util.tree;
|
package netwerkprog.game.util.tree;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
|
|
||||||
public class BST<E extends Comparable<E>> extends AbstractTree<E> {
|
public class BST<E extends Comparable<E>> extends AbstractTree<E> {
|
||||||
protected TreeNode<E> root;
|
protected TreeNode<E> root;
|
||||||
protected int size = 0;
|
protected int size = 0;
|
||||||
|
|
||||||
// Helper methode
|
|
||||||
public int sum () {
|
public int sum () {
|
||||||
return this.sum(this.getRoot());
|
return this.sum(this.getRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Opgave 1b (10 punten): Maak de recursieve methode sum af in de klasse bst.BST. Deze methode telt de getallen
|
|
||||||
// van alle elementen van de binaire zoekboom bij elkaar op. De methode geeft de totale som terug van alle getallen
|
|
||||||
// in de boom.
|
|
||||||
public int sum( TreeNode<E> node ) {
|
public int sum( TreeNode<E> node ) {
|
||||||
// Schrijf hier jouw code...
|
// Schrijf hier jouw code...
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
@@ -24,13 +18,10 @@ public class BST<E extends Comparable<E>> extends AbstractTree<E> {
|
|||||||
return sum(node.left) + sum(node.right);
|
return sum(node.left) + sum(node.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper methode
|
|
||||||
public int totalLeaves () {
|
public int totalLeaves () {
|
||||||
return this.totalLeaves(this.getRoot());
|
return this.totalLeaves(this.getRoot());
|
||||||
}
|
}
|
||||||
// Opgave 1c (10 punten): Maak de methode totalLeaves af om de klasse bst.BST. Deze methode telt het aantal
|
|
||||||
// bladeren (leaves) van de gegeven binaire zoekboom en geeft deze terug. Je hoeft deze methode niet recursief te
|
|
||||||
// implementeren. Het mag wel.
|
|
||||||
public int totalLeaves ( TreeNode<E> node ) {
|
public int totalLeaves ( TreeNode<E> node ) {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -58,7 +49,6 @@ public class BST<E extends Comparable<E>> extends AbstractTree<E> {
|
|||||||
|
|
||||||
private boolean search(E e, TreeNode<E> tree)
|
private boolean search(E e, TreeNode<E> tree)
|
||||||
{
|
{
|
||||||
// nog niet correct
|
|
||||||
if (tree == null)
|
if (tree == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -337,18 +327,4 @@ public class BST<E extends Comparable<E>> extends AbstractTree<E> {
|
|||||||
", " + res +
|
", " + res +
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (tree == null) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else if (e.compareTo(tree.element) > 0) {
|
|
||||||
// return search(e, tree.right);
|
|
||||||
// }
|
|
||||||
// else if (e.compareTo(tree.element) < 0) {
|
|
||||||
// return search(e, tree.left);
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,28 +2,28 @@ package netwerkprog.game.util.tree;
|
|||||||
|
|
||||||
public interface Tree<E> extends Iterable<E> {
|
public interface Tree<E> extends Iterable<E> {
|
||||||
/** Return true if the element is in the tree */
|
/** Return true if the element is in the tree */
|
||||||
public boolean search(E e);
|
boolean search(E e);
|
||||||
|
|
||||||
/** Insert element o into the binary tree
|
/** Insert element o into the binary tree
|
||||||
* Return true if the element is inserted successfully */
|
* Return true if the element is inserted successfully */
|
||||||
public boolean insert(E e);
|
boolean insert(E e);
|
||||||
|
|
||||||
/** Delete the specified element from the tree
|
/** Delete the specified element from the tree
|
||||||
* Return true if the element is deleted successfully */
|
* Return true if the element is deleted successfully */
|
||||||
public boolean delete(E e);
|
boolean delete(E e);
|
||||||
|
|
||||||
/** Inorder traversal from the root*/
|
/** Inorder traversal from the root*/
|
||||||
public void inorder();
|
void inorder();
|
||||||
|
|
||||||
/** Postorder traversal from the root */
|
/** Postorder traversal from the root */
|
||||||
public void postorder();
|
void postorder();
|
||||||
|
|
||||||
/** Preorder traversal from the root */
|
/** Preorder traversal from the root */
|
||||||
public void preorder();
|
void preorder();
|
||||||
|
|
||||||
/** Get the number of nodes in the tree */
|
/** Get the number of nodes in the tree */
|
||||||
public int getSize();
|
int getSize();
|
||||||
|
|
||||||
/** Return true if the tree is empty */
|
/** Return true if the tree is empty */
|
||||||
public boolean isEmpty();
|
boolean isEmpty();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user