Buongiorno a tutti,
ho il seguente problema, non riesco a capire perchè rivevo l'errore:
la riga dove ricevo l'errore è in neretto
(this.senderPerson.setName(sender.getName()); )
il codice dell'errore è nell'oggetto del thread
la situazione è la seguente:
nel main
dichiaro:
ora la classe Person è definita come segue:codice:Person sender, receiver; // imposto i valori degli oggetti sender e receiver // creo l'oggetto newBooking newBooking = new Booking(sender, receiver, pack);
la classe Booking :codice:public class Person implements PersonInterface { private String name; private String address; private String city; /** * Metodo costruttore con parametri * @param name - name and surname * @param addess - address * @param city - city */ public Person(String name, String address, String city) { this.name = name; this.address = address; this.city = city; } @Override public void setName(String name) { this.name = name; } @Override public String getName() { return this.name; } }
grazie a tutti per la rispostacodice:public class Booking implements BookingInterface { private Person senderPerson; public Booking(Person sender, Person receiver,Packages packages){ System.out.println(sender.getName()); this.senderPerson.setName(sender.getName()); } }

Rispondi quotando