public class Main{
public static void main(String[] args){
User u1 = new User("My Super Ex-Girlfriend", 5734);
User u2 = new User ("Morad", 5734);
User u3 = new User ("Fatma", 5734);
Network n = new Network("Telecom international", 5734);
Message m = new Message ("My Super Ex-Girlfriend", "Morad", "My heart in pain", " lets face it sweetie, you can go through a thousand girl to try to replace me but none of them will treat you like I did.");
u1.send(m);
n.add(u1);
n.add(u2);
System.out.println(u2.inbox.toString());
}
}
Waleeed
0
Newbie Poster
Recommended Answers
Jump to PostSend us the diagnostics that are emitted when the program is run on a command line.
Jump to PostWell, the error is happening in the User.send(Message) where it calls myNetwork.sendPendingEmailFrom(this). Since the myNetwork member of User u1 is still null, boom! :-)
Jump to Postin main you send the message (u1.send(m)) prior to add a user (n.add(u1)). So the order seems to be wrong.
Maybe you should also check whether a user exists or not in method Network.sendPendingEmailFrom.
All 11 Replies
Waleeed
0
Newbie Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Waleeed
0
Newbie Poster
Waleeed
0
Newbie Poster
Waleeed
0
Newbie Poster
Waleeed
0
Newbie Poster
Waleeed
0
Newbie Poster
Waleeed
0
Newbie Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
Waleeed
0
Newbie Poster
1stDAN
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.