Vehicle Class
Adding a toString( ) method to the Vehicle Class to override the default toString( ) method. First see what information the default toString( ) method returns.
Review Question -
1.
What is the difference between an Object Class and a Driver/Test Class?
2. Write down at least three different components that would be found in most classes. List them in the order they would be found.
3.
What object do I need in order to have the user input information to my program?
4. Write out a line of code that will print out the following "Java is the best class in all the....".
5. Which of the following are classes and which are variables and how can you tell?
Truck
numberOfCars
YEARS
age
Code Blocks format - just like an essay format { }
Programmer Created Classes - no main method - will NOT run, must be called by another class - a Driver class
The Driver (Test) class has a main method and within that main method it calls the methods of the programmer created class.
BOTH files must be in the same package to work!
Accessor/getter and Mutator/setter methods
- required so the Driver Class can access the data in the Object Class.
Java Key Words and camelCase
Variable names are short but meaningful in lower
camel case.
• Constant names are declared in uppercase letters with
the final modifier.
• Constructors are named the same as the class name.
• Methods are verbs named in lower camel case.
Complete Section 4: Lesson 2 - Object and Driver Classes Programs - show these to me for teacher check. Show me your two programs, Student and Person classes with their driver classes. See the Oracle curriculum.
The output of the StudentDriver class should be in the following form:
Student Name: Caron Newman
Student ID: 123456789
Student Status: Active
This program was created by .....
Section 4: Lesson 2 - Object and Driver Classes Vocabulary:
- A group of related Java classes.
-
Sections of code that are enclosed inside a set of curly braces. {}
-
First letter uppercase and the first letter of each internal word capitalized. Example: SavingsAccount
-
A named value that does not change.
-
First letter lowercase and the first letter of each internal word capitalized. Example: studentFirstName - A class that contains a main method.
-
A code statement in a Java class file that includes java code from another package or class.
-
A class that defines instances of objects to be used in another class.
-
Code that is preceded by //. Comments are used to clarify programming logic. Comments are ignored by the compiler.
-
A word that has a special function in the Java language, and cannot be used as names for classes, methods, or variables.
-
The library of Java classes available to import into a programmer-created class.
-
The outline of an object, including class variables, constructors, and methods.
-
A special kind of method that is a template for an object.
-
Values that are sent into a method or constructor to be used in a calculation or substituted with values from the class.
-
Values, such as numbers, characters, or booleans. References to objects, such as a BankAccount object. - Keywords used to specify the accessibility of a class (or type) and its members. Ex: public, private, protected, default
-
A block of code inside a class that is used to change or access information about the class.