One of the most important concepts in Information Technology is the ability of a learner to understand and create an object class.
Creating an object is a simple procedure if you are familiar with the basic requirements. Following the steps below to successfully create any object class.
- Create a public class and then place your attributes at the top of the class – remember to make them private as you only want them to be accessed from within the class.
- Create a default constructor and parameterised constructor with parameters for your attributes.
- Create a get (accessor) method for each attribute.
- Create a set (mutator) method for each attribute with checks and error checking if necessary.
- Create a toString() method that returns a string representation of all the attributes (data) of the object. If sample output is provided ensure that your toString output matches it.