Post date: Apr 20, 2017 6:30:22 AM
/!\ Quiz 2 is next week (week 12)
/!\ Sections 101 and 103: Quiz 1 will be on the first class
/!\ Section 102: Quiz 1 will be on the second class
Defining Classes 1
4.1 Class Definitions
Recommended Self-Test Exercises:
p 218: Ex. 3.
p 220: Ex. 4.
p 228: Ex. 5-9.
In-class Exercises:
Implement the following class:
Implement a NewStudent class with the following fields and methods:
Fields:
String name
double totalScore
int numberOfQuizzes
Methods:
public String getName()
public double getAverage() //this should return zero if no quiz has been taken.
public double getTotalScore()
public void printStudent() //this should print the student’s name and average score
Defining Classes 1
4.2 Information Hiding and Encapsulation
Recommended Self-Test Exercises:
p 231: Ex. 10-12.
p 249-250: Ex. 17-19.
Programming Exercises:
p 285: Ex. 3.
Class Rectangle (below) and its test program (see sample output):
Make sure the values entered for both length and width are positive numbers.
Class Circle (below) and its test program (similar to the previous example):
Make sure the values entered for radius are positive numbers.
Circumference = 2 • π • radius | Circle Area = π • r² | Sphere Volume = 4/3 • π • r³