• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to relate custom problem with well known Algorithms/problems  RSS feed

 
Mandar Khire
Ranch Hand
Posts: 588
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to write java program for 'call management system' associate with open-source softphone. Where person fill the form(Swing) as call comes to his pc's Softphone.
I try to keep simple & small my problem as this forum instruct always to me. My problem with not swing but with logic which i have to use. It might be possibility that this kind of question should not post in this section & should post in that section.
I dont know in which section it should be post.

My query is Some how i will manage the solution for my problem. But after that i have to prove i take help of Some famous Algorithm/problem provided in books example in Operating systems books shows
1. Sleeping barber problem
2. Dining philosophers problem
or Similar to this which is famous.

Scene:-
Background:-
1. I have 5 Electronics Devices(Actual Embedded phones) which sends Frames example Frame no 1:- Device State. two short values in that frame one device number second device state & many other types of variables for other values.
2. I have Frame-Receiver which receive properly those frames. (In frame receiver there is no problem all values geting properly always.)
3. Each device send 3 time Frame no 1. a. Trying b. Established c. End
4. I have Swing program which has 4 panels represent Device number inside Tabbedpane. Each panel have Textfields which should show Device state according to Device number & other related data.

Requirement
:-
If End comes then all textfields related to device number should be empty. Ready for next frame step by step (trying, Established, End).
At time t1 it may be 4 Devices send frames with any state. But It should be show accurate panel. No interfere with other device panel.
If 4 devices shows Establish then fifth should not send any frame. If by mistake frame receive then should not show in any panel.
It may possible that at period t1 to t2 only 1 device works or 2 or 3 or 4 also means all possibilities should be consider for solution.
It may happen Device 1,2,3,4 Established then suddenly 2 or 3 ends & again send step by step frame.
Means lots of possibilities should be consider by me.

What i done:-
My thinking:-
If 4 devices send frame at time then also all frame receive one after another serially.
So i try to make use of boolean flags for device state. Try to use if-elseif conditions with all possible conditions.
As in Mathematics something like probabilities
I make 3 flags for each device example
d1t (d1 trying)
d1es (d1 establish)
d1en (d1 end)

So by basic calculation i got 12 flags so combination with those i got 120 possibilities of combinations of flags.

My work:-
I done 3 java files 1. FrameReceiver 2.FrameData 3.Swing
In FrameReceiver.java i receive frame store its value in local variable pass it to FrameData.java
In FrameData.java has global static varibles which has getter-setter.
In Swing acutal Jpanel, JTabbedpane Jtextfields etc all swing related components.

If i consider only 1 Softpone with 1 Embedded phone then all programs work fine.

Question:- If i write all possibilities in if-else if condition then it may be huge & confusing code which will be very much head-ache.
For avoiding if-else i can use switch cases but that also might be huge(I prefer if-else till date due to never done complex programming.)

Can i get clue for this kind of custom made problem?
Mean some thing like well known problem/Algorithm or something like that?

I think it might be relate with 'Sleeping barber problem' which explain in Operating Systems books

There is 1 barber shop
4 Barbers(in books 3 considered)
1 Sofa for buffer
etc etc

Might be i am wrong. Need just clue/idea or moral support.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!