Commit ec704578 authored by THIBAULT Sebastien's avatar THIBAULT Sebastien
Browse files

Ajout des exercices, tous fonctionnels pour moi.

parent 62736fae
......@@ -4,3 +4,9 @@ This project only contains the gradle wrapper (and git ignore rules related to g
It was been generated using ``gradle wrapper``command.
The goal of this project is to allow users to easily bootstrap their gradle project without requiring they have locally their own gradle installation.
Début d'utilisation de Gradle
THIBAULT Sébastien
sebastien.thibault@telecomnancy.eu
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/4.10.2/userguide/tutorial_java_projects.html
*/
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building an application
id 'application'
}
// Define the main class for the application
mainClassName = 'eu.telecomnancy.App'
dependencies {
// This dependency is found on compile classpath of this component and consumers.
//compile 'com.google.guava:19.0'
// Deleted to prevent unknown issues
// Use JUnit test framework
testCompile 'junit:junit:4.+'
}
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven { url 'http://repo1.maven.org/maven2' }
}
/*
* This file was generated by the Gradle 'init' task.
*
* The settings file is used to specify which projects to include in your build.
*
* Detailed information about configuring a multi-project build in Gradle can be found
* in the user guide at https://docs.gradle.org/4.10.2/userguide/multi_project_builds.html
*/
rootProject.name = 'pcd2k18-gradle-bootstrap'
File added
package eu.telecomnancy;
public class App{
public static void main(String[] args){
Student Stud = new Student();
Student Stud2 = new Student();
Stud.setName("Jean Random");
Stud.setId(42);
Stud2.setName("Santa Open");
Stud2.setId(666);
System.out.println(Stud.toString());
System.out.println(Stud2.toString());
}
}
\ No newline at end of file
File added
package eu.telecomnancy;
public class Student{
private String name;
private int id;
public void setName(String name){
this.name = name;
}
public void setId(int id){
this.id = id;
}
public String getName(){
return this.name;
}
public int getId(){
return this.id;
}
public String toString(){
String res = "Student: Name:{"+ this.name + "} Id:{"+this.id+"}";
return res;
}
public boolean equals(Student Stud){
return (this.name==Stud.name) && (this.id == Stud.id);
}
}
File added
package eu.telecomnancy;
import org.junit.*;
public class StudentTest {
@Test
public void setANDget() {
Student Stud = new Student();
Stud.setName("Jean Random");
Stud.setId(42);
Assert.assertEquals(Stud.getName(),"Jean Random");
Assert.assertEquals(Stud.getId(),42);
}
@Test
public void equality(){
Student Stud = new Student();
Student Stud2 = new Student();
Stud2.setName("Jean Random");
Stud2.setId(42);
Stud.setName("Jean Random");
Stud.setId(42);
Assert.assertEquals(true,Stud.equals(Stud2)); // Equals
Stud.setId(43);
Assert.assertEquals(false,Stud.equals(Stud2)); // Different ID
Stud.setName("Thanos");
Assert.assertEquals(false,Stud.equals(Stud2)); // Different ID and name
Stud.setId(42);
Assert.assertEquals(false,Stud.equals(Stud2)); // Different name
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment