Skip to content

Commit

Permalink
Added methods to Setting. Created Language enum.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robin Strand Prestmo authored and Robin Strand Prestmo committed Feb 20, 2026
1 parent b143d6a commit 80c40a8
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.*;

// Unntakshåndtering mangler
// Enhetstester mangler

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ntnu.sytemutvikling.team6.models;

/**
* Supported application languages.
*
* @author Robin Strand Prestmo
*/
public enum Language {
ENGLISH,
NORSK
}
Original file line number Diff line number Diff line change
@@ -1,41 +1,77 @@
package ntnu.sytemutvikling.team6.models;

// Mangler unntakshåndtering
// Mangler Enhetstesting

/**
* Represents the settings for a user
* Represents the settings for a user.
*
* @Author Robin Strand Prestmo
* @author Robin Strand Prestmo
*/
public class Settings {
private boolean lightMode;
private String language;
private Language language;
private boolean anonymous;

/**
* Creates settings for a user
* Sets standard settings.
* LightMode enabled, language set to English,
* Anonymous disabled
*/
public Settings() {
this(true, Language.ENGLISH, false);
}
/**
* Creates settings for a user.
*
* @param lightMode choose between light or dark mode
* @param language choose language
* @param anonymous choose if user is anonymous
*
*/
public Settings(boolean lightMode, String language, boolean anonymous) {
public Settings(boolean lightMode, Language language, boolean anonymous) {
if (language == null) {
throw new IllegalArgumentException("Language cannot be null");
}
this.lightMode = lightMode;
this.language = language;
this.anonymous = anonymous;
}

public boolean getLightmode() {
/**
* Toggles between light and dark mode
*/
public void toggleLightMode() {
lightMode = !lightMode;
}

/**
* Toggles anonymous mode on and off
*/
public void toggleAnonymousMode() {
anonymous = !anonymous;
}

/**
* Change language to the chosen language.
*
* @param newLanguage the language to change to.
*/
public void changeLanguage(Language newLanguage) {
if (newLanguage == null) {
throw new IllegalArgumentException("Language cannot be null");
}
language = newLanguage;
}

public boolean isLightMode() {
return lightMode;
}

public String getLanguage() {
public Language getLanguage() {
return language;
}

public boolean getAnonymous() {
public boolean isAnonymous() {
return anonymous;
}
}

0 comments on commit 80c40a8

Please sign in to comment.