/* Craig Persiko
SimpleCourseTest.java
Defines and tests a class called Course which
holds information about a college course.
(Simpler version - not good class design)
*/
class SimpleCourse
{
// declare instance variables:
String dept, number, name; // package access by default (like public)
void printCourse() // package access by default (like public)
{
System.out.print(dept + number);
System.out.println(": " + name);
}
} // end of class Course definition
class SimpleCourseTest
{
public static void main(String[] args)
{
SimpleCourse cp110b = new SimpleCourse();
// constructor call (default constructor automatically generated)
cp110b.dept = "CIS";
cp110b.number = "110B";
cp110b.name = "Programming Fundamentals I, C++";
System.out.println("Info for " + cp110b.number);
cp110b.printCourse();
}
}
/* Output:
$ javac SimpleCourseTest.java
$ ls SimpleCourse*
SimpleCourse.class SimpleCourseTest.class
SimpleCourseTest.java
$ java SimpleCourseTest
Info for 110B
CIS110B: Programming Fundamentals I, C++
$
*/
syntax highlighted by Code2HTML, v. 0.9