Basically i want to create a class "Screws". This class shall describe a Screw by Type, length, thickness etc. I also want to create a "storage" class, that stores said "Screws" in all variances. The type, length etc. is limited to 7 and 3 (so there will be a limited amount of possibilities)
public class Screws{
public Screws(int typ,double durchmesser,double laenge,double gangHoehe){
this.schraubenArt = typ;
this.durchmesser=durchmesser;
this.laenge=laenge;
this.gangHoehe=gangHoehe;
}
}
Now i want to create a storage "unit", that will be an arraylist. I want to fill it with objects of "Screws". Afterwards i want to be able to check if a certain Scredobject is contained in the list.
import java.util.ArrayList;
public class Lager {
private Screws schrauben;
private ArrayList<Screws>Kreuzschlitzlager;
public Lager(){
Kreuzschlitzlager = new ArrayList<>();
for(int durchmesser=0; durchmesser <=3; durchmesser++){
for(int laenge=0; laenge <= 3; laenge++){
for(int ganghoehe=0; ganghoehe <=3; ganghoehe++){
Kreuzschlitzlager.add(new Screws (1,durchmesser,laenge,ganghoehe););
}}}}
public boolean checkForObject(Screws object){
return Kreuzschlitzlager.contains(object);
}
Now my problem is, i get a long list of objects i can "get" the properties of, but if i checkForObject(Anything) it will always give me a "false". I can't figure out why though. Don't worry about the class Screws, it's not nearly done. :D So, how do i check if an array list contains a certain object, why is it not working in this case and can i get the index of the object with .IndexOf?