1. Engineering
  2. Computer Science
  3. assignment instructions lets create a class pencil define 23 instance...

Question: assignment instructions lets create a class pencil define 23 instance...

Question details

Assignment Instructions:

  • Let’s create a class Pencil
    • Define 2-3 instance variables for the class
      • Example: the hardness (1 to 5) of the pencil’s lead or color of the pencil

           int hardness; //1 to 5

  • Define setter methods
    • Example: setHardness(int h);
  • Define getter methods
    • Example: int getHardness(); //returns hardness
  • Create tester() method to instantiate two different Pencil objects and test -- set and then output values.
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution