Class Student
Class Student
(Fig. 4.4) has features similar to those of class Account
(discussed in Chapter 3). Class Student
stores a student’s name and average and provides methods for manipulating these values. The class contains:
• instance variable name
of type String
(line 5) to store a Student
’s name
• instance variable average
of type double
(line 6) to store a Student
’s average in a course
• a constructor (lines 9–18) that initializes the name
and average
—in Section 5.9, you’ll learn how to express lines 15–16 and 37–38 more concisely with logical operators that can test multiple conditions
• methods setName
and getName
(lines 21–30) to set and get the Student
’s name
• methods setAverage
and getAverage
(lines 33–46) to set and get ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.