A2 ‣ Using Packages

Throughout the semester we’ll be using our git repository on cs.bridgewater.edu to store the files for the programs we write. When we write a class that can be instantiated in one assignment, we should write it so that it can be used in another assignment.  This requires us to

  1. include package declarations in reusable class files (but not drivers)
  2. include import statements
  3. include class modifiers
  4. include class member modifiers
  5. modify the CLASSPATH environmental variable

For this assignment, modify the Pair and Student classes that you wrote for the first assignment so that they belong to a package and are usable by classes in other packages.  Use your repository’s root directory as your package root.  Next, create a directory named a2 in your repository that includes a driver named Driver.java that creates a Pair instance and a Student instance and prints their fields to the console.  When complete, push all of the files that were created or modified to our GitHub repository.

 

 

© 2017 – 2019, Eric. All rights reserved.