Hello and welcome to 6W2 Summer 2015!


http://registrar.indiana.edu/official-calendar/official-calendar-summer.shtml

Atendance:        10%
Homework:         20%
Lab Assignments:  20% 
Midterm Exam:     20% 
Final Exam:       20% 
Semester Project: 10%

Attendance for today, as follows:

http://silo.cs.indiana.edu:8346/cgi-bin/sum2015/schedule

Make an appointment for Sat Jun 20. 

In C211 we studied Racket which is a type of Scheme which is type of Lisp. 

http://silo.cs.indiana.edu:8346/c212/spr2015/tetris.rkt

We are going to start with DrJava (IDLE)

http://www.drjava.org/

Download, move to Desktop, double-click. 

http://registrar.indiana.edu/browser/soc4155fac/CSCI/CSCI-C212.shtml

; A Point is a (make-point Integer Integer)
(define-struct point (x y))

(define a (make-point 7 2))
(define b (make-point -3 0))

Now we can say: 

Welcome to DrRacket, version 6.1.1 [3m].
Language: Intermediate Student with lambda; memory limit: 128 MB.
> a
(make-point 7 2)
> b
(make-point -3 0)
> (point? a)
true
> (point-x b)
-3
> (point-y a)
2


Java programs are made out of classes. 

Each class is written in its own file. 

There will be conventions I will ask you to follow. 

public class Point {
  int x, y; // instance variables 
  Point(int initialX, int initialY) { // constructor 
    x = initialX; 
    y = initialY; 
  }
  public String toString() { // displays what's inside the point 
    return "I am a Point at (" + x + ", " + y +")";  
  }
}

If I try this in the interactions panel:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> Point a = new Point(3, -1);
> a
I am a Point at (3, -1)
> a.x
3
> a.x = -5
-5
> a
I am a Point at (-5, -1)
>

Third party using my class: 

class LectureOne {
  public static void main(String[] args) {
     Point a, b; 
     a = new Point(3, 2);
     b = new Point(-1, 7); 
     System.out.println( a );
     System.out.println( b );
  }
}

Here's what I get if I compile and run this:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run LectureOne
I am a Point at (3, 2)
I am a Point at (-1, 7)


Now in lab we are going to focus exclusively on printing. 

class LabOne {
  public static void main(String[] args) {
    System.out.println( 2 );  
    System.out.println( 2 + 3);  
    System.out.println( "whatever" );  

  }
}

This produces, when compiled and run: 

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run LabOne
2
5
whatever


We will see you in lab.

--