Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
RadoRado
committed
Apr 21, 2016
1 parent
14b1118
commit fec0ad2
Showing
24 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
|
||
public class Box<T> { | ||
private T data; | ||
|
||
public Box(T data) { this.data = data; } | ||
public T getData() { return data; } | ||
|
||
public static void main(String[] args) { | ||
Box<Integer> a = new Box<>(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public abstract class Entity { | ||
private String id; | ||
|
||
protected String getId() { return id; } | ||
|
||
public abstract String getIdentifier(); | ||
|
||
public Entity(String id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return getIdentifier(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public abstract class Ivo extends Panda { | ||
@Override | ||
public void eat() { | ||
// TODO Auto-generated method stub | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class Magche extends Ivo { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
|
||
public class Main { | ||
public static void printArray(Object[] arr) { | ||
StringBuilder b = new StringBuilder(); | ||
b.append("["); | ||
for (int i = 0; i < arr.length; i++) { | ||
b.append(arr[i].toString()); | ||
|
||
if(i != arr.length - 1) { | ||
b.append(", "); | ||
} | ||
} | ||
|
||
b.append("]"); | ||
System.out.println(b.toString()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
Student ivo = new Student("8"); | ||
|
||
ArrayList<Entity> everything = new ArrayList<>(); | ||
everything.add(new Student("1")); | ||
everything.add(new Teacher("2")); | ||
everything.add(ivo); | ||
System.out.println(everything); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
|
||
public abstract class Panda { | ||
|
||
public Panda() {} | ||
public abstract void eat(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class Person implements Comparable<Person> { | ||
private String name; | ||
private int age; | ||
|
||
public Person(String name, int age) { | ||
this.name = name; | ||
this.age = age; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int getAge() { | ||
return age; | ||
} | ||
public void setAge(int age) { | ||
this.age = age; | ||
} | ||
|
||
public String toString() { | ||
StringBuilder b = new StringBuilder(); | ||
|
||
b.append("("); | ||
b.append(name); | ||
b.append(", "); | ||
b.append(age); | ||
b.append(")"); | ||
|
||
return b.toString(); | ||
} | ||
|
||
@Override | ||
public int compareTo(Person o) { | ||
if(this.age == o.age) { | ||
return 0; | ||
} | ||
|
||
if(this.age < o.age) { | ||
return -1; | ||
} | ||
|
||
return 1; | ||
} | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
16 changes: 16 additions & 0 deletions
16
lesson00/src/com/hackbulgaria/qa/week2/PersonComparator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
import java.util.Comparator; | ||
|
||
public class PersonComparator implements Comparator<Person>{ | ||
|
||
@Override | ||
public int compare(Person o1, Person o2) { | ||
if(o1.getAge() == o2.getAge()) { | ||
return o1.getName().compareTo(o2.getName()); | ||
} | ||
|
||
return o1.compareTo(o2); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class PythonRunner extends Runner { | ||
public PythonRunner(String code, String test) { | ||
super(code, test); | ||
} | ||
|
||
public void lint() {} | ||
public void compile() {} | ||
|
||
public void execute() { | ||
// Пусни python програмата в OS–а | ||
// Заедно с тестовете и кода | ||
// Гледай за някакви неща / while true / fork-loops и т.н | ||
// Вземи резултата | ||
result = "OK"; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
lesson00/src/com/hackbulgaria/qa/week2/RealPythonRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class RealPythonRunner extends PythonRunner { | ||
public RealPythonRunner(String code, String test) { | ||
super(code, test); | ||
} | ||
@Override | ||
public void execute() { | ||
super.execute(); | ||
result = "NOT OK"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public abstract class Runner { | ||
protected String result; | ||
protected String code; | ||
protected String test; | ||
|
||
public Runner(String code, String test) { | ||
this.code = code; | ||
this.test = test; | ||
} | ||
|
||
public String run() { | ||
lint(); | ||
compile(); | ||
execute(); | ||
|
||
return result; | ||
} | ||
|
||
public abstract void lint(); | ||
public abstract void compile(); | ||
public abstract void execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.NoSuchFileException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.List; | ||
|
||
public class SomeClass { | ||
|
||
public static void main(String[] args) { | ||
Path path = Paths.get("/home/radorado/code/Loki/R.md"); | ||
|
||
try { | ||
List<String> lines = Files.readAllLines(path); | ||
System.out.println(lines); | ||
} catch (NoSuchFileException fnfe) { | ||
System.out.println("File not found: " + fnfe.getMessage()); | ||
System.out | ||
.println("Please ensure that you have created the file, before running again."); | ||
fnfe.printStackTrace(); | ||
|
||
} catch (IOException e) { | ||
System.out.println(e.toString()); | ||
System.out.println("Here"); | ||
} catch(final Exception e) { | ||
throw e; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class Student extends Entity { | ||
public Student(String identifier) { | ||
super(identifier); | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return "Student::" + getId(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.hackbulgaria.qa.week2; | ||
|
||
public class Teacher extends Entity { | ||
|
||
public Teacher(String identifier) { | ||
super(identifier); | ||
} | ||
|
||
@Override | ||
public String getIdentifier() { | ||
return "Teacher::" + getId(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2.summary; | ||
|
||
public class A extends B implements C, D { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2.summary; | ||
|
||
public class B { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2.summary; | ||
|
||
public interface C { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2.summary; | ||
|
||
public interface D { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.hackbulgaria.qa.week2.summary; | ||
|
||
public class E extends A { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.hackbulgaria.week2.tdd; | ||
|
||
import java.util.Currency; | ||
|
||
import javax.transaction.InvalidTransactionException; | ||
|
||
public interface BankAccount { | ||
public Currency getCurrency(); | ||
public Integer getBalance(); | ||
public void deposit(Integer amount); | ||
public void withdraw(Integer amount) throws NotEnoughMoney; | ||
} |
41 changes: 41 additions & 0 deletions
41
lesson00/src/com/hackbulgaria/week2/tdd/BankAccountImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.hackbulgaria.week2.tdd; | ||
|
||
import java.util.Currency; | ||
|
||
public class BankAccountImpl implements BankAccount { | ||
|
||
private int currentBalance; | ||
|
||
public BankAccountImpl() { | ||
this(0); | ||
} | ||
|
||
public BankAccountImpl(int initialAmount) { | ||
this.currentBalance = initialAmount; | ||
} | ||
|
||
@Override | ||
public Currency getCurrency() { | ||
return Currency.getInstance("BGN"); | ||
} | ||
|
||
@Override | ||
public Integer getBalance() { | ||
return currentBalance; | ||
} | ||
|
||
@Override | ||
public void deposit(Integer amount) { | ||
currentBalance += amount; | ||
} | ||
|
||
@Override | ||
public void withdraw(Integer amount) throws NotEnoughMoney { | ||
if(currentBalance - amount < 0) { | ||
throw new NotEnoughMoney(); | ||
} | ||
|
||
currentBalance -= amount; | ||
} | ||
|
||
} |
Oops, something went wrong.