Programming Assignment-2
Programming Assignment-2
Chapter - 4
Faculty: Likhitha Kanagala
Programming Assignment-2
Name: __ __
Grade: _______
Section-I
1. Write a class called Number of Goals that represents the total number of goals scored by a football
team. The Number of Goals class should contain a single integer as instance data, representing the
number of goals scored. Write a constructor to initialize the number of goals to zero. Write a method
called set Goal that increments the value by one whenever a goal is scored, and another method called
get Goal that returns the total number of goals scored so far. Finally, create a driver class called Goal
Tracker that creates a few Numbers of Goals objects and tests their methods.
(OR)
2. Write a class called Bit Value that represents binary digits that can be set to true or false. Create a
driver class called Bits whose main method instantiates and sets a few bits to true.