Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a4e6eca
hw1
bzanardo Aug 29, 2018
689481e
junit path
bzanardo Sep 6, 2018
ee074bd
merge
bzanardo Sep 6, 2018
3fd3af4
Test
bzanardo Sep 7, 2018
c41ee19
Test2
bzanardo Sep 7, 2018
7b17c21
hwk2 (not working)
bzanardo Sep 7, 2018
424680f
race working
bzanardo Sep 7, 2018
9bfa675
tests
bzanardo Sep 7, 2018
4b5a187
Add files via upload
bzanardo Sep 9, 2018
5d19cc6
initial stage
bzanardo Sep 14, 2018
ecc2a4d
Merge branch 'master' of https://github.com/bzanardo/SoftwareEngineer…
bzanardo Sep 14, 2018
d7f0628
progress
bzanardo Sep 14, 2018
b49c883
Merge pull request #2 from SAREC-Lab/master
bzanardo Sep 14, 2018
5382384
progress
bzanardo Sep 14, 2018
1708fa3
ship movement
bzanardo Sep 14, 2018
2840c9b
islands
bzanardo Sep 14, 2018
e2b9ff5
add pirate ship
bzanardo Sep 14, 2018
e73cb97
observer pattern
bzanardo Sep 14, 2018
d8eaf80
uml diagram
bzanardo Sep 14, 2018
75a4662
reflection
bzanardo Sep 14, 2018
854ee09
correction of pirate ship movement
bzanardo Sep 16, 2018
060028d
Merge pull request #3 from SAREC-Lab/master
bzanardo Sep 17, 2018
366d46e
Merge pull request #4 from SAREC-Lab/master
bzanardo Sep 19, 2018
d81c964
homework4
bzanardo Sep 19, 2018
126d0d0
Merge branch 'master' of https://github.com/bzanardo/SoftwareEngineer…
bzanardo Sep 19, 2018
fa95d47
adding new track (no train)
bzanardo Sep 20, 2018
1ee2080
east train
bzanardo Sep 20, 2018
5fb115b
crossing road
bzanardo Sep 20, 2018
5b972cf
reflection
bzanardo Sep 21, 2018
e47e23f
resolving conflicts
bzanardo Sep 28, 2018
b1ef4b8
Merge branch 'SAREC-Lab-master'
bzanardo Sep 28, 2018
ba8aabc
chips challenge
bzanardo Sep 29, 2018
368fb89
chip challenge
bzanardo Sep 29, 2018
06b2492
first deliverable
bzanardo Sep 30, 2018
37c6098
chip movement
bzanardo Oct 8, 2018
ab00383
get chips to disappear
bzanardo Oct 11, 2018
6f7dcec
game states
bzanardo Oct 12, 2018
708fdab
progress
bzanardo Oct 13, 2018
c9591ab
monster strategy
bzanardo Oct 14, 2018
6655bbf
reset level
bzanardo Oct 14, 2018
fa1aabe
progess
bzanardo Oct 14, 2018
900055d
final
bzanardo Oct 16, 2018
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
Binary file added .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="/Users/bzanardo/eclipse/java-photon/plugins/junit-4.10.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/edu/.DS_Store
Binary file not shown.
Binary file added src/edu/nd/.DS_Store
Binary file not shown.
Binary file added src/edu/nd/se2018/.DS_Store
Binary file not shown.
Binary file added src/edu/nd/se2018/homework/.DS_Store
Binary file not shown.
19 changes: 18 additions & 1 deletion src/edu/nd/se2018/homework/hwk1/Question1.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
package edu.nd.se2018.homework.hwk1;
import java.util.*;

public class Question1 {

public Question1(){}

public int getSumWithoutDuplicates(int[] numbers){
return 0;
int total = 0;
Set<Integer> set = new HashSet<Integer>();
for (int i = 0; i < numbers.length; i++) {
if (!set.contains(numbers[i])) {
set.add(numbers[i]);
total += numbers[i];
}

}
return total;
}

public static void main(String[] args) {
int[] nums = {3, 3, 5, 5, 2};
Question1 getSum = new Question1();
int result = getSum.getSumWithoutDuplicates(nums);
System.out.println("The answer is:" + result);
}
}
48 changes: 47 additions & 1 deletion src/edu/nd/se2018/homework/hwk1/Question2.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,56 @@
package edu.nd.se2018.homework.hwk1;
import java.util.*;

public class Question2 {

public Question2(){}

public String getMostFrequentWord(String input, String stopwords){
return "";
HashMap<String, Integer> map = new HashMap<>();
Set<String> set = new HashSet<String>();
for (String stop : stopwords.split(" ")) {
if (!set.contains(stop)) {
set.add(stop);
}
}
for (String word : input.split(" ")) {
if (map.containsKey(word)) {
Integer n = map.get(word);
map.put(word, n + 1);
}
else {
if (!set.contains(word)) {
map.put(word, 1);
}
}
}
int max = 0;
String word = "";
Boolean duplicate = false;
for (Map.Entry<String, Integer> w : map.entrySet()) {
if (w.getValue() > max) {
max = w.getValue();
duplicate = false;
word = w.getKey();
}
else if (w.getValue() == max) {
duplicate = true;
}
}
if (duplicate == false) {
return word;
}
else {
return null;
}
}

public static void main(String[] args) {
String inputString2 = "giraffe elephant giraffe tiger tiger";
String stopWords = "and a hes the of up but with";
Question2 mostFrequentWord = new Question2();
String result = mostFrequentWord.getMostFrequentWord(inputString2, stopWords);
System.out.println("The answer is:" + result);
}

}
27 changes: 26 additions & 1 deletion src/edu/nd/se2018/homework/hwk1/Question3.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ public class Question3 {
public Question3(){}

public int getMirrorCount(int[] numbers){
return 0;
if (numbers.length == 0) {
return 0;
}
int count = 0;
for (int i = 0; i < numbers.length; i++) {
int num = (numbers.length) - 1 - i;

if (numbers[i] == numbers[num]) {
count++;
}
else {
count = 0;
}
}
if (count == 0) {
return 1;
}
else {
return count;
}
}

public static void main(String[] args) {
Question3 mirrorCount = new Question3();
int result = mirrorCount.getMirrorCount(new int[] {1,2,3,4,5});
System.out.println("The answer is:" + result);
}
}
20 changes: 20 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/EarlySprint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package edu.nd.se2018.homework.hwk2;

public class EarlySprint implements RaceStrategy {
@Override
public double runStrategy(double position, double maxSpeed) {
double p;
if (position <= 2) {
p = position + maxSpeed;
}
else if (position < 10) {
p = position + (0.75 * maxSpeed);
}
else {
p = 10;
}
return p;

}

}
Binary file not shown.
Binary file added src/edu/nd/se2018/homework/hwk2/HW2-uml.pdf
Binary file not shown.
46 changes: 46 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/Horse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package edu.nd.se2018.homework.hwk2;
import java.text.DecimalFormat;

import edu.nd.se2018.homework.hwk2.RaceStrategy;

public class Horse {
private static DecimalFormat df2 = new DecimalFormat(".##");

RaceStrategy raceStrategy;
public String name;
public int number;
public double position;
public double maxSpeed;

public Horse(RaceStrategy strategy, String n, int num, double p, double s) {
this.raceStrategy = strategy;
this.name = n;
this.number = num;
this.position = p;
this.maxSpeed = s;
}

public void run() {
double p = raceStrategy.runStrategy(this.position, this.maxSpeed);
this.position = p;
}

public void setStrategy(RaceStrategy strategy) {
this.raceStrategy = strategy;

}

public boolean done() {
if (position >= 10) {
return true;
}
else {
return false;
}
}

public void display() {
System.out.println(name + " is at position: " + df2.format(position));
}

}
15 changes: 15 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.nd.se2018.homework.hwk2;

public class Main {

public static void main(String[] args) {
Race race = new Race();
race.enrollHorse(new SteadyRun(), "Joe", 1, 0, 1);
race.enrollHorse(new EarlySprint(), "Mary", 2, 0, 1);
race.enrollHorse(new SlowStart(), "Spirit", 3, 0, 1);
race.enrollHorse(new EarlySprint(), "DingDing", 4, 0, 1);
race.enrollHorse(new SlowStart(), "Kelly", 5, 0, 1);
race.run();

}
}
33 changes: 33 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/Race.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package edu.nd.se2018.homework.hwk2;

public class Race {
public Horse[] horseArray = new Horse[5];
public int count = 0;
int miles = 10;
boolean done = false;
String winner = "";

public void enrollHorse(RaceStrategy rs, String n, int num, double p, double ms) {
this.horseArray[this.count] = new Horse(rs, n, num, p, ms);
this.count = this.count + 1;

}

public Race() {}

public void run() {
while (!done) {
for (int i = 0; i < this.count; i++ ) {
this.horseArray[i].run();
this.horseArray[i].display();
if (this.horseArray[i].done()) {
winner = this.horseArray[i].name;
done = true;
}
}
}
System.out.println("The winner is: " + winner);
}


}
6 changes: 6 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/RaceStrategy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package edu.nd.se2018.homework.hwk2;

public interface RaceStrategy {
public double runStrategy(double position, double maxSpeed);

}
36 changes: 36 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/RaceTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package edu.nd.se2018.homework.hwk2;
import org.junit.Test;

public class RaceTest {
@Test
public void test() { // Same strategies, different max speeds
Race race = new Race();
race.enrollHorse(new SteadyRun(), "A1", 1, 0, 1);
race.enrollHorse(new SteadyRun(), "B1", 2, 0, 1.2);
race.enrollHorse(new SteadyRun(), "C1", 3, 0, 1.4);
race.run();
assert(race.winner == "C1");
}

@Test
public void test2() { // Same strategies, different max speeds
Race race2 = new Race();
race2.enrollHorse(new SteadyRun(), "A2", 1, 0, 1);
race2.enrollHorse(new EarlySprint(), "B2", 1, 0, 1);
race2.enrollHorse(new SlowStart(), "C2", 3, 0, 1);
race2.run();
assert(race2.winner == "C2");
}

@Test
public void test3() {
Race race3 = new Race();
race3.enrollHorse(new SteadyRun(), "A3", 1, 0, 2);
race3.enrollHorse(new SlowStart(), "B3", 2, 0, 1);
race3.enrollHorse(new EarlySprint(), "C3", 3, 0, 1.1);
race3.enrollHorse(new SlowStart(), "D3", 4, 0, 0.8);
race3.enrollHorse(new SteadyRun(), "E3", 5, 0, 0.9);
race3.run();
assert(race3.winner == "A3");
}
}
21 changes: 21 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/SlowStart.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package edu.nd.se2018.homework.hwk2;

public class SlowStart implements RaceStrategy {
public double runStrategy(double position, double maxSpeed) {
double p = position;
if (position <= 6) {
p = position + (0.75 * maxSpeed);
}
else if (position <= 1) {
p = position + (0.9 * maxSpeed);
}
else if (position < 10){
p = position + maxSpeed;
}
else {
position = 10;
}
return p;
}

}
15 changes: 15 additions & 0 deletions src/edu/nd/se2018/homework/hwk2/SteadyRun.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package edu.nd.se2018.homework.hwk2;

public class SteadyRun implements RaceStrategy {
public double runStrategy(double position, double maxSpeed) {
double p;
if (position < 10) {
p = position + (0.8 * maxSpeed);
}
else {
p = 10;
}
return p;
}

}
Binary file added src/edu/nd/se2018/homework/hwk3/.DS_Store
Binary file not shown.
5 changes: 5 additions & 0 deletions src/edu/nd/se2018/homework/hwk3/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions src/edu/nd/se2018/homework/hwk3/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>hwk3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Binary file not shown.
Binary file added src/edu/nd/se2018/homework/hwk3/HW3-uml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading