Hey,
for school i need to learn java. We have had some small projects but here i get stuck. Is there someone who van help me?
There are 3 files below. 2 sub and 1 main.
I need to connect the 2 with eachother and let the main display the info.
Outcome, Lid@addbf1 needs to be Erik, what am i doing wrong??
Code:De titel van het boek is boeka en het is geschreven door auteura. De titel van het boek is boekb en het is geschreven door auteurb. De nieuwe titel van het boek is boekaa Lid@addbf1
Boek.javaCode:public class Boek { /* * (non-javadoc) */ private Lid lid; /** * Getter of the property <tt>lid</tt> * * @return Returns the lid. * */ public Lid getLid() { return lid; } /** * Setter of the property <tt>lid</tt> * * @param lid The lid to set. * */ public void setLid(Lid lid ){ this.lid = lid; } private String titel; private String auteur; private boolean isUitgeleend; private int hoeVaakUitgeleend; public Boek (String titel, String auteur) { this.titel = titel; this.auteur = auteur; this.isUitgeleend = false; this.hoeVaakUitgeleend = 0; } public void setTitel (String titel) { this.titel = titel; } public void setAuteur (String auteur) { this.auteur = auteur; } public void setIsUitgeleend (boolean isUitgeleend) { this.isUitgeleend = isUitgeleend; } public void setHoeVaakUitgeleend (int hoeVaakUitgeleend) { this.hoeVaakUitgeleend = hoeVaakUitgeleend; } public String getTitel () { return titel ; } public String getAuteur () { return auteur; } public boolean getIsUitgeleend () { return isUitgeleend; } public int getHoeVaakUitgeleend () { return hoeVaakUitgeleend; } } ///** // * Getter of the property <tt>lid</tt> // * // * @return Returns the lid. // * // */ //public Lid getLid() //{ // return lid; //} ///** // * Setter of the property <tt>lid</tt> // * // * @param lid The lid to set. // * // */ //public void setLid(Lid lid ){ // this.lid = lid; //}
Lid.java
BibAdmin.javaCode:public class Lid { /* * (non-javadoc) */ private Boek boek; /** * Getter of the property <tt>boek</tt> * * @return Returns the boek. * */ public Boek getBoek() { return boek; } /** * Setter of the property <tt>boek</tt> * * @param boek The boek to set. * */ public void setBoek(Boek boek ){ this.boek = boek; } public Lid(String naam, String adres){ this.naam = naam; this.adres = adres; this.aantalBoeken = 0; } /* * (non-javadoc) */ private int aantalBoeken; /** * Getter of the property <tt>aantalBoeken</tt> * * @return Returns the aantalBoeken. * */ public int getAantalBoeken() { return aantalBoeken; } /** * Setter of the property <tt>aantalBoeken</tt> * * @param aantalBoeken The aantalBoeken to set. * */ public void setAantalBoeken(int aantalBoeken ){ this.aantalBoeken = 0; } /* * (non-javadoc) */ private String adres; /** * Getter of the property <tt>adres</tt> * * @return Returns the adres. * */ public String getAdres() { return adres; } /** * Setter of the property <tt>adres</tt> * * @param adres The adres to set. * */ public void setAdres(String adres ){ this.adres = adres; } /* * (non-javadoc) */ private String naam; /** * Getter of the property <tt>naam</tt> * * @return Returns the naam. * */ public String getNaam() { return naam; } /** * Setter of the property <tt>naam</tt> * * @param naam The naam to set. * */ public void setNaam(String naam ){ this.naam = naam; } } ///** // * Setter of the property <tt>boek</tt> // * // * @param boek The boek to set. // * // */ //public void setBoek(Boek boek ){ // this.boek = boek; //} ///** // * Getter of the property <tt>boek</tt> // * // * @return Returns the boek. // * // */ //public Boek getBoek() //{ // return boek; //}
Code:public class BibAdmin { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Boek a = new Boek ("boeka", "auteura"); Boek b = new Boek ("boekb", "auteurb"); Boek c = new Boek ("boekc", "auteurc"); Boek d = new Boek ("boekd", "auteurd"); System.out.println("De titel van het boek is "+a.getTitel()+ " en het is geschreven door "+ a.getAuteur()+ "."); System.out.println("De titel van het boek is "+b.getTitel()+ " en het is geschreven door "+ b.getAuteur()+ "."); a.setTitel("boekaa"); System.out.println("De nieuwe titel van het boek is "+a.getTitel()); Lid e = new Lid ("Erik", "Ronde weg"); Lid f = new Lid ("Frank", "Vierkante weg"); Lid g = new Lid ("Gert", "Ovale weg"); Lid h = new Lid ("Henkjan", "Rechte weg"); a.setIsUitgeleend(true); a.setHoeVaakUitgeleend(+1); e.setAantalBoeken(+1); a.setLid(e); e.setBoek(a); System.out.println(a.getLid()); } }




Reply With Quote