Skip to content

Commit

Permalink
Apply new Utils methods in EditChallengesGUI
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Sep 5, 2019
1 parent e900f1e commit e5ec5d5
Showing 1 changed file with 6 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,12 +358,16 @@ else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.OTHER)
if (clickType.isRightClick())
{
this.challenge.setChallengeType(
this.getPreviousType(this.challenge.getChallengeType()));
Utils.getPreviousValue(
Challenge.ChallengeType.values(),
this.challenge.getChallengeType()));
}
else
{
this.challenge.setChallengeType(
this.getNextType(this.challenge.getChallengeType()));
Utils.getNextValue(
Challenge.ChallengeType.values(),
this.challenge.getChallengeType()));
}

this.build();
Expand Down Expand Up @@ -1205,62 +1209,6 @@ else if (this.challenge.getChallengeType().equals(Challenge.ChallengeType.OTHER)
}


/**
* This method returns next challenge type from given.
* @param type Given challenge type.
* @return Next Challenge Type.
*/
private Challenge.ChallengeType getNextType(Challenge.ChallengeType type)
{
Challenge.ChallengeType[] values = Challenge.ChallengeType.values();

for (int i = 0; i < values.length; i++)
{
if (values[i].equals(type))
{
if (i + 1 == values.length)
{
return values[0];
}
else
{
return values[i + 1];
}
}
}

return type;
}


/**
* This method returns previous challenge type from given.
* @param type Given challenge type.
* @return Previous Challenge Type.
*/
private Challenge.ChallengeType getPreviousType(Challenge.ChallengeType type)
{
Challenge.ChallengeType[] values = Challenge.ChallengeType.values();

for (int i = 0; i < values.length; i++)
{
if (values[i].equals(type))
{
if (i > 0)
{
return values[i - 1];
}
else
{
return values[values.length - 1];
}
}
}

return type;
}


// ---------------------------------------------------------------------
// Section: Enums
// ---------------------------------------------------------------------
Expand Down

0 comments on commit e5ec5d5

Please sign in to comment.