diff --git a/src/tp01/Book.java b/src/tp01/Book.java index 9aab7d3ca2c17e89d819724fbeed9e5b5f362fda..0cdfaec397a04baae4330d55f7bf35d5a5176435 100644 --- a/src/tp01/Book.java +++ b/src/tp01/Book.java @@ -2,24 +2,23 @@ package tp01; class Book { - // class attributes - String author; - String title; - int year; - // constructor - Book(String author, String title, int year) { + private String author; + private String title; + private int year; + + public Book(String author, String title, int year) { this.author = author; this.title = title; this.year = year; } - // methods - String getAuthor() { + + public String getAuthor() { return this.author; } - String getTitle() { + public String getTitle() { return this.title; } - String print() { + public String print() { return author + "\t" + title + "\t" + year; } diff --git a/src/tp01/HighScore.java b/src/tp01/HighScore.java index eed524d818169a8562a0af9321cd54f3b8e244f6..042d89980c0c6c2f7e555d21d191ac2930be2f04 100644 --- a/src/tp01/HighScore.java +++ b/src/tp01/HighScore.java @@ -23,7 +23,7 @@ public class HighScore { for (int i = 0; i < top.length; i++) { - if (top[i] == null || newScore.sc > top[i].sc) + if (top[i] == null || newScore.getSc() > top[i].getSc()) { // Décale les éléments vers la droite pour faire de la place for (int j = top.length - 1; j > i; j--) { diff --git a/src/tp01/RandomSequence.java b/src/tp01/RandomSequence.java index 12403cf8feaa2a106f95fb637942d59325186eb0..ed33e3acbd05a8e3ffafc281c5f78a7f0f7f492d 100644 --- a/src/tp01/RandomSequence.java +++ b/src/tp01/RandomSequence.java @@ -4,9 +4,9 @@ import java.util.Random; public class RandomSequence { - int nbGen; - int valMax; - String intOrReal = "INTEGER"; + private int nbGen; + private int valMax; + private String intOrReal = "INTEGER"; public RandomSequence(int n, int v, String i) { @@ -14,6 +14,19 @@ public class RandomSequence this.valMax = v; this.intOrReal = i; } + + public int getNbGen() { + return nbGen; + } + + public int getValMax() { + return valMax; + } + + public String getIntOrReal() { + return intOrReal; + } + public static void main(String[] args) { if(Integer.parseInt(args[0]) >= 1 && Integer.parseInt(args[1]) >= 1) diff --git a/src/tp01/Score.java b/src/tp01/Score.java index 3974559858816e04485c2e585f40c0656fb56713..f616a8c5c043836137cc6b407387b3b6df4d0e54 100644 --- a/src/tp01/Score.java +++ b/src/tp01/Score.java @@ -2,9 +2,9 @@ package tp01; public class Score { - String n = "Empty"; - int sc = 0; - String tS = "00/00"; + private String n = "Empty"; + private int sc = 0; + private String tS = "00/00"; public Score(String name, int score, String timestamp) { @@ -13,6 +13,10 @@ public class Score this.tS = timestamp; } + public int getSc() { + return sc; + } + @Override public String toString() {