I am developing a MineSweeper. In that I have 3 packages. 1.frontEnd 2.backEnd 3.mineSweeperControl.
mineSweeperControl contains an class ActionSplicer which implements ActionListener.In frontEnd I have an array of JBUTTONS and an array of ActionSplicer objects, such that splicerobj[i][j] listens to button[i][j].(one to one correspondence)
backEnd contains an array of objects such that object[i][j] has the background details of button[i][j] such as MineValue,isCellEmpty,isCellFlagged etc...
Method doBackgroundAction(i,j){..} is defined in class BackEndManager. In actionPerformed of ActionSplicer, I call doBackgroundAction(i,j) so that the any change in foreground will also affect the background.
Where my problem is?
The doBackGroundAction(i,j) needs to be public since it is called in different package.
But I don't want any method to be public, since it may reduce the flexibility and then any person can change the values of attributes.
I cannot extend the class BackEndManager since I am creating an array of ActionSplicer objects in frontEnd.
Hence I need some sort of guidance about declaring doBackGroundAction(i,j). Whether it is right way to declare the methods as public in some non-avoidable situvation? Or How can I change my design to retain the method with default visibility.