Computer Science 1
Top Lectures Assignments Noticeboard

Defining classes, Part 1

Reading: Chapter 5.1-5.4.7

Numeric Processing

  • If we have variables that contain integer values, we can construct arithmetic expressions:
  • x+y
    x+(y/z)
    mph/distance
    rate*hours
  • We can also print out ints, using the print and println methods of PrintStream
  • System.out.println (rate*hours);
  • Primitive data types are not classes
  • To declare a variable that can contain an int value, we declare it using the same template as we do for other variables:
  • int hoursInDay = 24;
  • Why use integers?
  • Using ints in a class/program.

    Statement of problem

    Sample scenario

    Finding the primary objects

    Determining the behavior of the class Employee

    Defining the interface for class Employee

    Implementing methods


    Last modified: 2/15/99