2016-10-26 HW

posted Oct 24, 2016, 10:36 PM by Samuel Konstantinovich   [ updated Oct 25, 2016, 7:12 AM ]
Sorry for late notice:
The Innovention Club participates in NYU Polytech's yearly Tandon competition. For the competition, we have to build an original product, hardware or software, or improve on an already existing one. At the competition, they will grade our product based on how complex it is, what impact will it have on society, and how well it implements current technology. Moving away from the competition, the Innonvetion Club also has a heavy focus on just getting people to innovate.   Interest meeting : Wednesdsay 10/26 @ room 333


DO NOW:

/*************************************************************************************/
//What is the output of running the main?
class A {
    public int i;
    public void display() {
        System.out.println(i);
    }
}    
class B extends A {
    public int j;
    public void display() {
        System.out.println(j);
    }
}    
class inheritance_demo {
    public static void main(String args[])
    {
        B obj = new B();
        obj.i=1;
        obj.j=2;   
        obj.display();     
        ((A)obj).display();
    }
}



//SAMPLE CODE FOR ANOTHER QUESTION
public class Superclass {
    private void doSomething(){System.out.println("from Superclass");}
    public static void main (String[] args){
        Superclass obj = new Subclass();
        obj.doSomething(); //prints "from Superclass"
    }
}

class Subclass extends Superclass {
    private void doSomething(){System.out.println("from Subclass");}
}

//Which of these is not allowed? Why?
Superclass s1 = new SuperClass();
Superclass s2 = new SubClass(); 
Subclass sub1 = new SuperClass(); 
Subclass sub2 = new SubClass();




/*************************************************************************************/
GOAL: Ya'll are such little Arrays of sunshine.

int[]varname;           //reference to an array of ints
varname = new int[10];  //instantiate the array to the specified size 

Now we can look at the 10 locations of the array by using the square braces:
varname[0] = 10;
varname[1] = 3;
System.out.println(varname[0]+varname[1]);

for(int i = 0; i < varname.length; i++){
    varname[i] = (int)(Math.random()*10);
}

System.out.print("[ ");
for(int i = 0; i < varname.length; i++){
    System.out.print(varname[i]+" ");
}
System.out.println("]");


CODINGBAT HW/Classwork:

Arrays1:
 rotateLeft3
Arrays2:
 countEvens
 fizzArray3
 without10
 isEverywhere
 fizzBuzz  
Arrays3: 
 maxSpan

Comments