CSCI A201/A597

Lecture Notes Nineteen

Second Summer 2000


Chapter 3 review.
Draw this:
class A {

} 

Draw this:
class B {

  int u;
  double q;

} 

Draw this:
class Student {

} 

Draw this:
class Student {

  int age; 

} 

Draw this:
class Z {

  int m; 
  double n; 

} 

Draw this:
class M {
  
  int m; 
  static double n;

} 

Draw this:
class Q {

  int v; 
  double z;

  public static void main(String[] args) {

  } 

} 

Draw this:
class E {
  
  int v; 
  double z;
  
  public static void main(String[] args) {

    int q; 
    
    q = 3; 

  } 

} 

Draw this:
class Student {

  int age; 
  double gpa; 

  public static void main(String[] args) {
 
    int q = 21; 
    String n = "John"; 

  } 

} 

Draw this:
class J {
  
  int x; 
  
  public  static void main(String[] args) {

    J z = new J(); 
    int x = 5; 
    z.x = 5; 

  } 

} 

Draw this:
class Student {

  int age;
  double gpa; 

  public static void main(String[] args) {

    int q;
    String n; 
    Student s;

    s = new Student(); 

  }

} 

Draw this:
class Student {
  
  int age = 20; 
  double gpa; 

  public static void main(String[] args) {

    Student s = new Student(); 
    Student q = new Student(); 
    q.age = 19; 
    s.age = 21; 
    q.age = 3 + q.age; 

  }

} 

Now write this: Create two accounts, Doug's doubles, Adrian's decreases by 3, then Doug's account has one more dollar deposited to it. .

Draw this:
class BankAccount {
  double balance = 25; 

  public static void main(String[] args) {

    BankAccount doug = new BankAccount(); 
    BankAccount adrian = new BankAccount();

    doug.balance = doug.balance * 2; 
    adrian.balance -= 3; 

    doug.balance++; 
    

  } 

} 

Draw this:
class Account {
  
  double balance = 10; 
  
  public static void main(String[] args) {

    Account m = new Account(); 
    Account q = new Account(); 

    m.deposit(10); 
    n.deposit(3); 

  } 

  void deposit (int n) {
    this.balance += n; 
  } 

} 

Draw this:
class Account {
  
  double balance; 
  
  Account(double x) {

  } 

  public static void main(String[] args) {
    Account m = new Account(10); 
    Account q = new Account(3); 
    m.balance = 10 + m.balance; 
  }

} 

Draw this:
class X {

  int x; 

} 

Draw this:
class A {
  
  int x;

  A (int initialValue) {
    this.x = initialValue; 
  } /* do this when you first create the
    object but don't make this part of the
    object */ 

} 

Write this:

Draw this:
class Student {
  String name; 
  Student (String w) {
    this.name = w; 
  } 
} 

class Friday {
  public static void main(String[] args) {
    Student q = new Student("Larry"); 
    Student u = new Student("John"); 
    Student s = new Student("Adrian"); 
  } 
} 

Draw this:
class Checking {

  double balance; 
  
  Checking(double x) {
    this.balance = x; 
  } 

  void deposit(double y) { 
    this.balance = this.balance + y; 
  }

} 

Draw this:
class Tea {
  
  double bird; 

  void book(double watch) { // int z = 3;  
    this.bird = watch - this.bird; 
  }

  Tea (double snake) {
    this.bird = snake * 2; 
  }

} 

Draw this:
class Hat {
  public static void main(String[] args) {
    
    Tea m = new Tea(-2); 
    Tea n = new Tea(42); 

    m.book(92); 
    n.bird = m.bird + n.bird;

    n.book(25); 
    n.book(25); 

  } 
} 

Draw this:
class X {
  int q;
} 

class Play {
  public static void main(String[] args) {
    X u = new X(); 
    X p = new X(); 
    u.q = 3; 
    p.q = u.q + p.q; 
    u.q = u.q + p.q; 
  } 
} 

Last updated: July 20, 2000 by Adrian German for A201