From cadf5b6a1d10a9e64181d89da2933bf3ff96a9cf Mon Sep 17 00:00:00 2001 From: Halzyn Date: Thu, 23 Apr 2015 17:12:43 +0200 Subject: Implemented high score list and sorting --- .../java/com/camilstaps/rushhour/HighScore.java | 19 +++++++++++++- .../com/camilstaps/rushhour/HighScoreList.java | 29 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/camilstaps/rushhour/HighScoreList.java (limited to 'app/src') diff --git a/app/src/main/java/com/camilstaps/rushhour/HighScore.java b/app/src/main/java/com/camilstaps/rushhour/HighScore.java index 87c9816..ce5e001 100644 --- a/app/src/main/java/com/camilstaps/rushhour/HighScore.java +++ b/app/src/main/java/com/camilstaps/rushhour/HighScore.java @@ -2,8 +2,9 @@ package com.camilstaps.rushhour; /** * Created by camilstaps on 23-4-15. + * Edited by Halzyn on 23-4-15. */ -public class HighScore { +public class HighScore implements Comparable { private final int score; private final String name; @@ -21,4 +22,20 @@ public class HighScore { return name; } + @Override + public int compareTo(HighScore other_score) { + if (other_score.getScore() < score) + { + return -1; + } + else if (other_score.getScore() == score) + { + return 0; + } + else + { + return 1; + } + } + } diff --git a/app/src/main/java/com/camilstaps/rushhour/HighScoreList.java b/app/src/main/java/com/camilstaps/rushhour/HighScoreList.java new file mode 100644 index 0000000..c0a7e67 --- /dev/null +++ b/app/src/main/java/com/camilstaps/rushhour/HighScoreList.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package rushhour; + +import java.util.Collections; +import java.util.List; + +/** + * + * @author Created by halzyn on 23-4-15. + */ +public class HighScoreList { + + private List list; + + public HighScoreList (List some_list) { + this.list = some_list; + } + + public void addToList(HighScore score) + { + list.add(score); + Collections.sort(list); + } + +} -- cgit v1.2.3 From 3f1039136d8debe7cb10051f6a28abbf30d017f5 Mon Sep 17 00:00:00 2001 From: Halzyn Date: Thu, 23 Apr 2015 17:13:16 +0200 Subject: Victory tune --- app/src/main/res/raw/victory.wav | Bin 0 -> 325838 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/src/main/res/raw/victory.wav (limited to 'app/src') diff --git a/app/src/main/res/raw/victory.wav b/app/src/main/res/raw/victory.wav new file mode 100644 index 0000000..e11f4ff Binary files /dev/null and b/app/src/main/res/raw/victory.wav differ -- cgit v1.2.3