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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access