Hi Leute ich habe gerade meine täglichen Übungsaufgaben gemacht was ganz gut klappt nur habe ich in folgendem Code einen boolean der eigentlich auf true sein müsste der aber als false ausgegeben wird. Was habe ich also nicht richtig gemacht?:
Code:
import java.util.Objects;
public class FotoApparat {
private static final int MIN_brennweite=10;
private static final int MAX_brennweite=270;
private int megaPixel;
private double displayGroesse;
private boolean bildStabisiert;
private String marke;
private int brennweiteMin;
private int brennweiteMax;
private String herstellungsLand;
public FotoApparat(int megaPixel,double displayGroesse,boolean bildStabisiert,
String marke,int brennweiteMin,int brennweiteMax,String herstellungsLand)
{
super();
megaPixel =this.megaPixel;
displayGroesse= this.displayGroesse;
bildStabisiert= this.bildStabisiert;
marke= this.marke;
brennweiteMin= this.brennweiteMin;
brennweiteMax=this.brennweiteMax;
herstellungsLand= this.herstellungsLand;
}
public String getHerstellungsLand() {
return herstellungsLand;
}
public void setHerstellungsLand(String herstellungsLand) {
this.herstellungsLand = herstellungsLand;
}
public void machFoto()
{
System.out.println("Klick");
}
public static int hashCode(FotoApparat apple)
{
return Objects.hashCode(apple);
}
@Override
public String toString()
{
return "Kameramarke "+ marke+" Megapixel "+ megaPixel+" Displaygroeße "
+displayGroesse+" Bild ist stabilisiert " + bildStabisiert+" Minimale Brennweite"
+brennweiteMin+" Maximale Brennweite"+brennweiteMax+" Herstellungsland:"+herstellungsLand;
}
public int getMegaPixel() {
return megaPixel;
}
public void setMegaPixel(int megaPixel) {
this.megaPixel = megaPixel;
}
public double getDisplayGroesse() {
return displayGroesse;
}
public void setDisplayGroesse(double displayGroesse) {
this.displayGroesse = displayGroesse;
}
public boolean isBildStabisiert() {
return bildStabisiert;
}
public void setBildStabisiert(boolean bildStabisiert) {
this.bildStabisiert = bildStabisiert;
}
public String getMarke() {
return marke;
}
public void setMarke(String marke) {
this.marke = marke;
}
public int getBrennweiteMin() {
return brennweiteMin;
}
public void setBrennweiten(int brennweiteMin, int brennweiteMax)
{
if(brennweiteMin <=brennweiteMax)
{
brennweiteMax=this.brennweiteMax;
brennweiteMin=this.brennweiteMin;
}
else
{
System.err.println("Die minimale Brennweite muss kleiner als die maximale Brennweite sein!");
}
}
public int getBrennweiteMax() {
return brennweiteMax;
}
}
Code:
import java.util.Objects;
public class FotoShooting {
public static void main(String[] args) {
FotoApparat apple= new FotoApparat(18,7.5,true,"SoNie",18,200,"Japan");//Megapixel,Displaygroeße,Bildstabisiert,marke,
System.out.println(apple); //brennweiteMin dann max,herstellungsland
FotoApparat canon= new FotoApparat(19,8.5,true,"Canon",55,200,"Japan");
System.out.println(canon);
}
}