Below is the presentation I used for my talk on Anti-If Campaign for Cincy Clean Coders today.
The source code used in the presentation is available in github.
The source code used in the presentation is available in github.
abstract class A{
def isWhat():Boolean
}
trait B extends A{
override def isWhat():Boolean = true;
}
trait C extends A{
override def isWhat():Boolean = false;
}
val a = new A with C with B;
println(a.isWhat());
public class AList<E> {
private final List<E> list;
public AList(List<E> list) {
super();
this.list = list;
}
public boolean add(E value){
return this.list.add(value);
}
public int size(){
return this.list.size();
}
public E[] toArray(E[] a) {
System.arraycopy(list.toArray(), 0, a, 0, size());
return a;
}
}
@Test
public void testAListToArray() {
AList list = new AList(new ArrayList());
list.add("Not type safe");
String[] sl = (String[]) list.toArray(new String[list.size()]);
assertEquals(sl.length, list.size());
AList<String> list2 = new AList<String>(new ArrayList<String>());
list2.add("Type safe");
String[] s2 = list2.toArray(new String[list.size()]);
assertEquals(s2.length, list2.size());
}
public void findSquareCubeNumbers(int count){
for (int i = 1; i < count; i++){
int num = i*i*i;
for (int j = 1; j < count; j++){
int sum = i+j;
if (num+(j*j)==sum*sum){
System.out.println(i+"+"+j+"="+sum);
}
}
}
}
public void findNextPowerNumbers(int powVal, int count){
double prevK = 0;
for(double i = 1; i < powVal; i++){
double power = i+1;
for (double k = 1; k < count; k++){
double num = Math.pow(k, power);
double num1 = Math.pow(k, i);
double sum = 2*k;
double num3 = Math.pow(sum, i);
if (num+num1 == num3){
System.out.println("(k= "+k+"((2*"+prevK+")+1); n= "+i+") "+k+"^"+i+"+"+k+"^"+power+"="+sum+"^"+i);
prevK=k;
}
}
}
}