Skip to content
This repository was archived by the owner on May 8, 2022. It is now read-only.

Chapter 3

chyneyee edited this page Mar 4, 2015 · 4 revisions

Chapter 3: Introduction to Classes and Objects


Table of Contents

Figures

Figure No. Description Filename
Fig. 3.1 Class declaration with one method. GradeBook.java
Fig. 3.2 Create a GradeBook object and call its displayMessage method. GradeBookTest.java
Fig. 3.4 Class declaration with a method that has a parameter. GradeBook2.java
Fig. 3.5 Create GradeBook object and pass a String to its displayMessage method. GradeBook2Test.java
Fig. 3.7 GradeBook class that contains a courseName instance variable and methods to set and get its value. GradeBook3.java
Fig. 3.8 Create and manipulate a GradeBook object. GradeBook3Test.java
Fig. 3.10 GradeBook class with a constructor to initialize the course name. GradeBook4.java
Fig. 3.11 GradeBook constructor used to specify the course name at the time each GradeBook object is created. GradeBook4Test.java
Fig. 3.13 Account class with a constructor to initialize instance variable balance. Account.java
Fig. 3.14 Inputting and outputting floating-point numbers with Account objects. AccountTest.java
Fig. 3.17 Printing multiple lines in dialog box Dialog1.java
Fig. 3.18 Basic input with a dialog box. NameDialog.java

Note: All the figures in this chapter originally are named as GradeBook.java and GradeBookTest.java. The committed files are numbered (GradeBook2, GradeBook3, GradeBook4) to distinguish the different examples.

Exercises

Exercise No. Description Filename
Exercise 3.8 Modify class GradeBook (Fig. 3.10) - include a course's instructor instance variable, get set method, modify the constructor and the method displayMessage. Exercise038.java
Exercise 3.8 A test application for Exercise038.java Exercise038Test.java
Exercise 3.9 Modify class Account (Fig. 3.13) to provide a method called debit that withdraws money from an Account. Ensure that the debit amount does not exceed the Account's balance. Exercise039.java
Exercise 3.9 A test application for Exercise039.java Exercise039Test.java
Exercise 3.10 Create a class called Employee that includes three pieces of information as instance variables, a constructor and get set methods. Display the monthly salary and yearly salary after given 10% raise Employee.java
Exercise 3.10 A test application named EmployeeTest that demonstrates class Employee's capabilities and create two Employee objects and display each object's yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary again. EmployeeTest.java
Clone this wiki locally