0

I have a MetroStop class as below:

public class MetroStop {
public int identifiant;
public double longitude;
public double latitude;
public String nom;
public String destination;
public String moyen;

public MetroStop() {
    
}

public MetroStop(int identifiant, double longitude, double latitude, String nom, String destination, String moyen) {
    this.identifiant = identifiant;
    this.longitude = longitude;
    this.latitude = latitude;
    this.nom = nom;
    this.destination = destination;
    this.moyen = moyen;
}

I read from a file with the following format:

11339855#2.39216908162993#48.7905387877103#AUDIGEOIS#VITRY-SUR-SEINE#bus

From this file's lines I create MetroStop objects and add them to an ArrayList. After adding all the objects, I do the following assertion to verify if a specific object is in the list.

 MetroStop testMetro = new MetroStop(446306, 2.40895224652756, 48.8674280733386, "SEVERINE", "PARIS-20EME", "tram");
    assertThat(teste.listeArrets.contains(testMetro), is(true));

The testMetro object is created from the data of a random line in the file, thus I am sure that the list contains it. I have also printed all the elements of the list and I could see the exact same object as testMetro, but the assertion is false because contains returns false. Can you please help me to understand why do I get false? Thank you!

Will Wost
  • 105
  • 2
  • 9

0 Answers0