Chapter:Classes - Using packages - Exercises

From Juneday education
Jump to: navigation, search

Exercises on grouping stuff in packages

This exercise aims to make you reflect on how one could divide classes into packages.

Given the following classes for some project, how could you divide the classes into directories (and packages) which better describe their role in the project? Be creative! There is not one single answer to this question, you have to use your imagination here.

$ ls -1
Book.java
Main.java
MathStuff.java
Newspaper.java
TestMathStuff.java
TextUtilities.java

Solutions to grouping stuff in packages

Expand using link to the right to see one possible solution.

One possible division could be the following:

.
|-- literature
|   |-- Book.java
|   `-- Newspaper.java
|-- main
|   `-- Main.java
|-- math
|   `-- MathStuff.java
|-- test
|   `-- TestMathStuff.java
`-- text
    `-- TextUtilities.java

Links

Further reading

Where to go next

Next page is: Classes_-_Testing_your_classes

« PreviousBook TOCNext »