Skip to content
Snippets Groups Projects
Commit 4fdaee0b authored by Samuel Turpin's avatar Samuel Turpin :computer:
Browse files

tp1 fix and add public and private attribute

parent fe6270ac
Branches
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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--) {
......
......@@ -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)
......
......@@ -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()
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment