Skip to content
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
12 changes: 12 additions & 0 deletions BasicJavaRecap-2.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

3 changes: 3 additions & 0 deletions out/production/BasicJavaRecap-2/dummy1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a test file.
It's content is going to be copied do the dummy2 file.
Let's test it out!
3 changes: 3 additions & 0 deletions out/production/BasicJavaRecap-2/dummy2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This is a test file.
It's content is going to be copied do the dummy2 file.
Let's test it out!
4 changes: 4 additions & 0 deletions out/production/BasicJavaRecap-2/dummy3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

!tuo ti tset s'teL
.elif 2ymmud eht od deipoc eb ot gniog si tnetnoc s'tI
.elif tset a si sihT
3 changes: 3 additions & 0 deletions out/production/BasicJavaRecap-2/filenames.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src/numbers1.txt
src/numbers2.txt
src/numbers3.txt
10 changes: 10 additions & 0 deletions out/production/BasicJavaRecap-2/numbers1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-12
0
302
21
10
11
12
13
14
1
7 changes: 7 additions & 0 deletions out/production/BasicJavaRecap-2/numbers2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-20
1
300
20
10
-2
-30000
6 changes: 6 additions & 0 deletions out/production/BasicJavaRecap-2/numbers3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-200
10
300
20
10
-200
67 changes: 67 additions & 0 deletions src/com/elte/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.elte;

import java.util.Arrays;
import java.util.List;

public class Board {

boolean[][] board_;
int nLines_;
int nColumns_;

public int getnLines_() {
return nLines_;
}

@Override
public String toString() {

StringBuilder board = new StringBuilder();

for (int line = 0; line < this.nLines_; line++){
for (int column = 0; column < this.nColumns_; column++){
if (!this.board_[line][column]){
board.append('.');
}else{
board.append('X');
}
board.append('\t');
}
board.append('\n');
}
return board.toString();
}

public int getnColumns_() {
return nColumns_;
}

public Board(int lines, int columns) {
this.board_ = new boolean[lines][columns];
this.nLines_ = lines;
this.nColumns_ = columns;
}

public boolean markHitFields(List<Coordinate> coords){
boolean returnStatus = true;
for (Coordinate coord: coords) {
if (!this.markHitField(coord)){
returnStatus = false;
}
}
return returnStatus;
}

public boolean markHitField(Coordinate a){
if (((int) a.getX() < 0) || ((int) a.getX() >= this.nLines_) ||
((int) a.getY() < 0) || ((int) a.getY() >= this.nColumns_) ||
this.board_[(int) a.getX()][(int) a.getY()]){
// Invalid hit
System.out.println("Invalid hit. Unconsidered.");
return false;
}

this.board_[(int) a.getX()][(int) a.getY()] = true;
return true;
}
}
18 changes: 18 additions & 0 deletions src/com/elte/ComparatorInts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.elte;

import java.util.Comparator;
import java.util.Map;

public class ComparatorInts implements Comparator<String> {

Map<String, Integer> base;

public ComparatorInts(Map<String, Integer> base) {
this.base = base;
}

@Override
public int compare(String s1, String s2) {
return base.get(s1).compareTo(base.get(s2));
}
}
29 changes: 29 additions & 0 deletions src/com/elte/Coordinate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.elte;

public class Coordinate {

private double x_;
private double y_;

public Coordinate(double x, double y){
x_ = x;
y_ = y;
}

public String toString() {
return "(" + Double.toString(x_) + "," + Double.toString(y_) + ")";
}

double getX(){
return x_;
}

double getY(){
return y_;
}

double getDistanceFrom(Coordinate b){
return Math.sqrt( Math.pow((double)(b.getX() - x_), 2) + Math.pow((double)(b.getY() - y_), 2));
}
}

Loading