Facing problem while programming mediator problem using Java
5 posters
Page 1 of 1
Facing problem while programming mediator problem using Java
মাথা চরম গরম অবস্থায় mediator pattern দিয়ে একটি problem solve করার সময় NullPointerException খাচ্ছি
একে তো code করায় অভ্যাস নেই তেমন তার উপর মাথা গরম
আমি নিশ্চত চরম কোনো বোকামি করেছি যাতে logic ই গোলমেলে হয়ে গেছে
এখানে program টা দিচ্ছি। কোনো সহৃদয় ব্যক্তিকি আমার problem টা solve করে দিবেন?
The problem :
Make a chat server where a chat room will exits. A user can register but he/she don't have to be logged in(registration is equal to log in system here). User can see who is in the chat room(that means who is in the registered users list.) Message passing will occur between two users through the chat room.
ChatRoom Class
User Class
Main Class
একে তো code করায় অভ্যাস নেই তেমন তার উপর মাথা গরম
আমি নিশ্চত চরম কোনো বোকামি করেছি যাতে logic ই গোলমেলে হয়ে গেছে
এখানে program টা দিচ্ছি। কোনো সহৃদয় ব্যক্তিকি আমার problem টা solve করে দিবেন?
The problem :
Make a chat server where a chat room will exits. A user can register but he/she don't have to be logged in(registration is equal to log in system here). User can see who is in the chat room(that means who is in the registered users list.) Message passing will occur between two users through the chat room.
ChatRoom Class
User Class
Main Class
Last edited by BIT0122-Amit on Sat Jan 29, 2011 3:17 am; edited 1 time in total (Reason for editing : edited title, used icon)
Re: Facing problem while programming mediator problem using Java
Please tell me the specific line number where you got NullPointerException. It is almost impossible to read the whole code from here.
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: Facing problem while programming mediator problem using Java
It shows the exception in the User class's line 26 -
with the Main's line no.12 -
You can also download them clicking the Download raw to check them by running in your IDE
- Code:
chat.send(reciever,msg, sender);
with the Main's line no.12 -
- Code:
u1.sendMsg("vua", "amar matha gorom");
You can also download them clicking the Download raw to check them by running in your IDE
Re: Facing problem while programming mediator problem using Java
ai code dekhbo na...
I can give you a better idea,
press Ctrl+A then shift + Delete.
I can give you a better idea,
press Ctrl+A then shift + Delete.
Re: Facing problem while programming mediator problem using Java
I think you got Exception in User class line number 26. Because you did not initialize the "User sender" declared in line number 9.
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: Facing problem while programming mediator problem using Java
বিশাল গলদ। তোর মাথা যে আসলেই গরম তা বুঝতে পারছি।
এখানে আমি যদি ঠিক করে দেই, তাহলে আসলে তোর কোড টা আর তোর থাকবে না, আমার কোড হয়ে যাবে।
তাও করলাম- নিজেই দেখ-
Difference হিসেবে করেছি-
এটা main class
http://pastebin.com/diff.php?i=GQKR826J
এটা user class
http://pastebin.com/diff.php?i=hsZ64Bbq
এটা chatroom
http://pastebin.com/diff.php?i=Uxqvr5he
আর আমি difference হিসেবে দিয়েছি। মূল কোড দেখতে চাইলে "diff.php?i=" টা কেটে দিলেই হবে।
এখানে আমি যদি ঠিক করে দেই, তাহলে আসলে তোর কোড টা আর তোর থাকবে না, আমার কোড হয়ে যাবে।
তাও করলাম- নিজেই দেখ-
Difference হিসেবে করেছি-
এটা main class
http://pastebin.com/diff.php?i=GQKR826J
এটা user class
http://pastebin.com/diff.php?i=hsZ64Bbq
এটা chatroom
http://pastebin.com/diff.php?i=Uxqvr5he
আর আমি difference হিসেবে দিয়েছি। মূল কোড দেখতে চাইলে "diff.php?i=" টা কেটে দিলেই হবে।
Last edited by BIT0122-Amit on Sat Jan 29, 2011 3:04 am; edited 1 time in total
Re: Facing problem while programming mediator problem using Java
I got the point
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: Facing problem while programming mediator problem using Java
- Code:
ai code dekhbo na...
আর বাংলাটা বাংলায় লেখার অনুরোধ জানাচ্ছি
I have applied your Ctrl+A then shift + Delete process to my previous mediator code before I wrote this code
By the way Toma, you can download the full project from here also. It's just about 3KB
Re: Facing problem while programming mediator problem using Java
ভালো কথা, যে যাই বলুক, তুই অন্ততঃ চেষ্টা করেছিস। সেটাই আমি চাই বং আশা করি সবার কাছ থেকে।
কোড পারি না বলে স্বীকার করা বা কোডে ভুল করেছি বলার করার সৎসাহস সবার থাকে না। :/
কোড পারি না বলে স্বীকার করা বা কোডে ভুল করেছি বলার করার সৎসাহস সবার থাকে না। :/
Re: Facing problem while programming mediator problem using Java
Toma , তুই যেই point টা পাইছিস এটা এখানে বল please
Amit এর টা দেখে বুঝতে গেলে আসলেই মনে হচ্চে কোডটা আর আমর কোড থাকবেনা
BTW, অমিতকে অনেক ধন্যবাদ
Amit এর টা দেখে বুঝতে গেলে আসলেই মনে হচ্চে কোডটা আর আমর কোড থাকবেনা
BTW, অমিতকে অনেক ধন্যবাদ
Re: Facing problem while programming mediator problem using Java
আমি বলছি তো
BIT0107-toma wrote:I think you got Exception in User class line number 26. Because you did not initialize the "User sender" declared in line number 9.
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Re: Facing problem while programming mediator problem using Java
Toma, I tried your advise..but it didn't work
Re: Facing problem while programming mediator problem using Java
I have found my problem checking with Amit's given solution here
The problem was simply in calling recieveMsg inside the send method
Thanks to Amit
Toma for your effort
The problem was simply in calling recieveMsg inside the send method
Thanks to Amit
Toma for your effort
Re: Facing problem while programming mediator problem using Java
কোড টা দেখবো না, এর পেছনে কারণ:
আমরা ডিজাইন প্যাটার্ন করতেছি, তার মানে আমরা আসলে OOC জানি। OOC এর মধ্যে Encapsulation নামক একটা শব্দ আছে যার প্রায়োরিটি মোটামুটি ৭০%।
যদি আমরা Encapsulation কে বাদ দেই, বাকি থাকে ৩০%। তারমানে আসলে OOC এর কিছুই হইনাই। একেক্ষত্রে আসলে ডিজাইন প্যাটার্ন শেখার কোন দরকার নাই এবং এই কোড আসলে শিফট ডিলিট করায় সবচেয়ে ভাল সমাধান।
১ বছর OOC শেখার পর, কারো মাথায় যদি না ঢুকে যে, ভেরিয়েবল গুলা প্রাইভেট রাখা উচিৎ, সেক্ষত্রে কোডটা না পড়তে চাওয়া খুব খারাপ কিছু না, আমার মতে। এই এতগুলো কথা অন্য কারও বুঝতে অসুবিধা হলেও অত্যন্তপক্ষে যাকে বলেছি, আমি নিশ্চিৎ সে বুঝতে পেরেছে।
আমরা ডিজাইন প্যাটার্ন করতেছি, তার মানে আমরা আসলে OOC জানি। OOC এর মধ্যে Encapsulation নামক একটা শব্দ আছে যার প্রায়োরিটি মোটামুটি ৭০%।
যদি আমরা Encapsulation কে বাদ দেই, বাকি থাকে ৩০%। তারমানে আসলে OOC এর কিছুই হইনাই। একেক্ষত্রে আসলে ডিজাইন প্যাটার্ন শেখার কোন দরকার নাই এবং এই কোড আসলে শিফট ডিলিট করায় সবচেয়ে ভাল সমাধান।
১ বছর OOC শেখার পর, কারো মাথায় যদি না ঢুকে যে, ভেরিয়েবল গুলা প্রাইভেট রাখা উচিৎ, সেক্ষত্রে কোডটা না পড়তে চাওয়া খুব খারাপ কিছু না, আমার মতে। এই এতগুলো কথা অন্য কারও বুঝতে অসুবিধা হলেও অত্যন্তপক্ষে যাকে বলেছি, আমি নিশ্চিৎ সে বুঝতে পেরেছে।
BIT0110-sumon- Pre-Alpha Release
- Posts : 4
Points : 4
Re: Facing problem while programming mediator problem using Java
BIT0122-Amit wrote:আমি খারাপ টা ছিলাম কবে :O :O
BIT0107-Toma- Programmer
- Course(s) :
- BIT
Blood Group : B+
Posts : 280
Points : 453
Similar topics
» Need suggestions on scaling an image and making it transparent
» Web programming with Java, Spring Framework, part 1
» Web programming with Java, Spring framework, part 3
» Java Help needed: Problem with using graphics
» Problem creating executable jar file in java
» Web programming with Java, Spring Framework, part 1
» Web programming with Java, Spring framework, part 3
» Java Help needed: Problem with using graphics
» Problem creating executable jar file in java
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Tue Sep 29, 2015 2:45 pm by Sophiawood
» Cisco EHWIC SFP/GE WAN Card
Mon Sep 07, 2015 11:08 am by Sophiawood
» Huawei S1700-28GFR-4P-AC Price
Thu Jun 25, 2015 2:31 pm by Sophiawood
» teach yourself C++ / Herbert Schildt Solutions
Wed Jun 03, 2015 1:52 pm by Abdullah Al Noman
» teach yourself c by herbert schildt pdf
Wed May 13, 2015 11:01 pm by Raquib Ridwan
» ASA 5506X With Firepower ASA5506-K9
Fri Apr 10, 2015 4:31 pm by Sophiawood
» New Trends in Deal Business
Tue Feb 03, 2015 9:38 pm by nersoa
» PoE Power Allocation for WS-C2960S-24PS-L
Wed Nov 05, 2014 11:12 am by Sophiawood
» How to cure back pain
Fri Oct 31, 2014 7:15 pm by Bergen Guildford