Added documentation.

This commit is contained in:
Alexei KADIR 2024-03-30 14:54:08 +01:00
parent 66b6842516
commit 63c865e82a
2 changed files with 58 additions and 15 deletions

View File

@ -7,21 +7,38 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.widget.Button;
/**
* {@code MainActivity} is the activity that displays the main menu.
*
* @autor Alexeï Kadir, Lyanis Souidi, Hugo Dimitrijevic
* @version 1.0
*/
public class MainActivity extends AppCompatActivity {
/**
* The {@code Button} that starts the game when clicked.
*/
private Button play;
/**
* The {@code Button} that opens the settings when clicked.
*/
private Button settings;
/**
* The {@code Button} that exits the application when clicked.
*/
private Button exit;
/**
* The {@code MainController} that controls the main menu.
*/
private MainController mainController;
/**
* Creates the main menu.
*
* @param savedInstanceState The saved instance state.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

View File

@ -9,23 +9,41 @@ import android.view.View;
import java.util.prefs.Preferences;
/**
* {@code MainController} is a class that controls the main menu by recieving
* events from the {@code MainActivity}.
*
* @autor Alexeï Kadir, Lyanis Souidi, Hugo Dimitrijevic
* @version 1.0
*/
public class MainController implements View.OnClickListener {
/**
* The key of the preference that stores the size of the cross.
*/
private static final String SIZE_PREFERENCE_KEY = "size_preference";
/**
* The key of the preference that stores whether the game is in hard mode.
*/
private static final String HARD_MODE_PREFERENCE_KEY = "hard_mode_preference";
/**
* The {@code Activity} that contains the main menu.
*/
private final Activity activity;
/**
* Creates the main menu controller.
*
* @param activity The {@code Activity} that contains the main menu.
*/
public MainController(Activity activity) {
this.activity = activity;
}
/**
* Starts a new game with the settings from the preferences.
*/
public void play() {
SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this.activity);
@ -40,17 +58,25 @@ public class MainController implements View.OnClickListener {
this.activity.startActivity(intent);
}
/**
* Opens the settings.
*/
public void openSettings() {
this.activity.startActivity(new Intent(this.activity, SettingsActivity.class));
}
/**
* Exits the application.
*/
public void exit() {
this.activity.finish();
}
/**
* Handles a click event from the main menu.
*
* @param view The {@code View} that was clicked.
*/
@Override
public void onClick(View view) {
int id = view.getId();