Is my approach to this problem correct?

Hi, I'm new to Java and OO programming, and this is my first coding experience
in Java, so, be patient...!
I'd like to know if the approach I'm adopting for the following exercise is
acceptable. Hints and critics on how could I improve it are the reason for this
post, I don't want you make my homeworks ;-)
The exercise asks to realize a simple list of telephone numbers containing
namesurname/telephonenumber couples (namesurnames are unique). The
list must be saved permanently on the disk, the user may be able to search a number
providing a name, to add a new record, to remove and modify an existing record.
Finally, it can be possible to load different data files. All these operations
must be available via GUI.
I still don't know how to create GUIs, so I thought that as a first step it
could be a good move to develop the set of API to
save/load/search/add/remove/change, and once these API work fine, create a GUI
that uses these API.
I have identified just one class that models this problem: the class that
represents the whole set of names and telephone numbers, and I'd like to use it
in this manner:
nameNumsList.search("namesurname");
nameNumsList.insert("namesurname", "number");
nameNumsList.remove("namesurname");
nameNumsList.change("namesurname", "number");
nameNumsList.load("filename");
nameNumsList.save("filename");
To handle data persistence, I will store each item (one item for line) in a
file, in this form: namesurname;number.
To load data from file to memory I have been attracted to java.util.TreeMap, as
this data structure:
* provides ascending order of keys, that is useful for an ordered representation of keys/numbers;
* offers methods to obtain values from keys (get), to add and modify
keys/values (put) and to remove a key and its associated value (remove).
One of the things that make me dubious is how to implement the filesystem to
memory (load list) and the memory to filesystem (save list) bridge..
Thanks for any suggestion,
Paolo

I tought the same thing, initially. But, suppose that
name/number list contains 10000 records, and that I
change just one of them.
Do I understand correctly if I say that when I change
a record of the list and want to save the change, I
must iterate over 10000 records to save just one
change?Yes, or just wait with the save till the application is about to exit. (You would probably use a database instead if this was a commercial application)
Kaj

Similar Messages

  • Hello I was charged twice for adobe story plus, I need this problem corrected and a refund issued for one of the subscription charges, I tried chatting with Adobe and they were unable to help me. Where is email support?

    Hello I was charged twice for adobe story plus, I need this problem corrected and a refund issued for one of the subscription charges, I tried chatting with Adobe and they were unable to help me. Where is email support?

    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"
    -or by telephone http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

  • Need suggestions or possible approach for this problem

    Hello,
    I have a scenario and I want to develop an apex application for this scenario.
    The thing is I have mutiple report regions on a page which are querying the same tbl 'loans'. I have a button named 'Assign loan' at the top of the page and at bottom of the page I have buttons 'Save' and 'Complete'. Initially the multiple report regions should not be displayed, only after user clicks on the buton 'Assign loan', then only they should be visible. Similarly for the buttons 'Save' and 'Complete'. After the loan is assigned to a user the button 'Assign loan' should be disabled.
    Now Consider a situation where in a user logins to the application and clicks on the button 'Assign a loan', at this point i will update the table and set a flag, so that the user will get that particular record for the reports region. I mean this record should be locked for that user and shouldn't be available for other users. The thing it should work in a multi-user environment, i mean each user should get a different loan when they click the button 'Assign loan'. So, here the user is assigned a loan and he/she makes changes to the multiple report region editable items and he/she can either save the changes by clicking on the button 'Save' or they can click on the button 'Complete' which means the loan was reviewed and is completed. The user shouldn't be assigned an another loan until he/she reviews and completes a paticular loan already assigned to him. And another case would be the user does some changes to the multiple report region editable items and clicks the button 'Save' (menaing pending) the report changes should be saved and he shouldn't be assigned any new loan until he completes the already assigned loan.
    Can anyone please help me with their possible suggestions or an approach to this kind of problem.
    thanks,
    Orton

    It looks to me that the trickiest part is preventing more than one user from getting assigned the same loan. I've seen DBMS_LOCK used for a situation like this. It's been years so I'm a bit fuzzy on the exact details but it goes something like this:
    When the user clicks 'Assign a loan', try to get an exclusive generic lock:
       dbms_lock.request(lockhandle => 'LOAN_LOCK',
                      lockmode   => dbms_lock.X_MODE,
                      timeout    => 10);If another user already has a lock with this name, try again after the timeout until the lock is obtained (and probably only try a maximum number of times).
    Once the lock is obtained, get the next available unassigned loan and set the flag in the table. Now release the lock so the next user can get a loan assigned.
       dbms_lock.release(lockhandle => 'LOAN_LOCK');As long as everyone uses the same process for getting a loan assigned, only the user with a lock can modify the table. The rest of it (the logic around what buttons to show, requiring an assigned loan to be completed before getting another one assigned, etc.) should be relatively straightforward.

  • Best approach for this problem

    Hi there Experts,
    I have an Async Sync Bridge BPM, to go from Delivery Idocs to Webservice Calls, after that i map the response to a an ALEAUD Idoc structure and i send it back to erp to update the Delivery Status.
    Currently its working as intended on production system, but the Deliveries quantity is growing exponentially, raising the response times for the whole process.
    I found a solution for this problem, instead of making 1 Webservice call for each delivery, i can group those deliveries and send multiple deliveries per each webservice call, the problem i have appears when i need to map this response to single ALEAUD Idocs.
    To Update the original delivery Idoc i need that idoc number onto the ALEAUD, but the webservice returns the response based on delivery number, therefore i need a mechanism, maybe a temporal table or something, that allows me to store the idoc number with the matching delivery number so i can use it as reference to map the huge response to single ALEAUD Idocs, also i'd like to know if this is possible to achieve using graphical mapping or wich would be the best way to do it.
    Thanks for all the input on the matter,
    Regards,
    Roberto.

    Maybe you can write 2 RFC function modules to maintain values in ECC and the other to read it. These RFC's can be called from within mapping.
    I dont know if it will work or not, but can be tried.

  • When I attempt to open a PDF file I saved from a website, I get the message "There was an error opening this document. The file is damaged and could not be repaired." Is there any way to correct this problem?

    When I attempt to open a PDF file I saved from a website using Safari, I get the message "There was an error opening this document. The file is damaged and could not be repaired." When I save the same PDF file using FireFox it opens up immediately. Is there any way to correct this problem with Safari?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Every time I try to download an app it says billing info is incorrect but its all correct it won't let me sign in using a diff apple id even when I reset my phone anyone else had this problem if so how do I fix it?

    Every time I try to download an app it says billing info is incorrect but its all correct it won't let me sign in using a diff apple id even when I reset my phone anyone else had this problem if so how do I fix it?

    Amylovelyy wrote:
    Every time I try to download an app it says billing info is incorrect but its all correct ...
    Contact iTunes Customer Service and request assistance
    Use this Link  >  Apple  Support  iTunes Store  Contact
    Amylovelyy wrote:
    ...  it won't let me sign in using a diff apple id ...
    Settings > iTunes and App store > Apple ID = Sign Out... Then Sign In using the preferred Apple ID.
    It should be Noted that anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID.

  • All of a sudden my iTunes stopped working, and I get the following error messages:   1. the program can't start because MSVCR80.dll is missing from your computer. Try reinstalling the program to fix this problem   and   2. iTunes was not installed correct

    All of a sudden my iTunes stopped working, and I get the following error messages:
    1. the program can't start because MSVCR80.dll is missing from your computer. Try reinstalling the program to fix this problem
    and
    2. iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 126).
    Now I've checked the forums and followed the advice of uninstalling all Apple applications, rebooting, and reinstalling iTunes.
    This is not working. I've tried installing as Administrator but doesn't make any difference at all.
    There must be a way to fix this? I'm not a tech geek but I want to avoid having to take my laptop back to factory settings to sort this out.
    Thanks

    Click here and follow the instructions. You may need to completely remove and reinstall iTunes and all related components, or run the process multiple times; this won't normally affect its library, but that should be backed up anyway.
    (99192)

  • SINCE INSTALLING I.E. 11 IN WINDOWS 7, UNABLE TO DOWNLOAD OR SAVE FILES IN FIREFOX; HOW DO I CORRECT THIS PROBLEM?

    This is what I wrote to the Microsoft Community seeking a correction of the issue (still no reply to my request for assistance with this matter from them):
    Can I go back to I.E. 10? Ever since I installed version 11, I've had an unstable desktop. It appears to have damaged the Windows Explorer interface in other browsers, such that when I open the popup window to save downloads and/or other files, all that shows up in the window are the "Save" and "Cancel" buttons, but it does not show the interface to choose where to save the file(s), thus I cannot save anything at all in those other browsers. I primarily use Firefox, and every time I want to save a file, I have to startup I.E. 11 to save anything and everything.
    I would much prefer going back to I.E. 10 which caused me no such problems; but, if I cannot go back to I.E. 10, how do I correct this issue so I can save files in other browsers? This situation has been going on for months now, and I've waited patiently thinking that there would be an update for Microsoft and/or Firefox (as well as Chrome and Safari) that would correct this problem by now; but, even though I have all of the latest updates and versions installed, no updates have corrected the issue at all. I would very much appreciate any help you can give.
    Oh, also, I have tried uninstalling Firefox completely at least twice, and rebooting before reinstalling it to the latest version, but that has not corrected the problem either. I additionally tried turning I.E. 11 off in Windows, and then tried running Firefox to see if the download interface would be restored, but it still had the very same issue(s) [no ability to choose the place to save files, and thus being completely unable to save any downloads and/or other files]. I can't believe that this problem has been going on for so long now without any update(s) resolution.

    The following is the latest that I've written to Microsoft about this entire matter:
    You're still not getting it. I've never had a problem with downloading and/or saving files in I.E.; and I very clearly explained to you guys that the problem is in the other browsers, but it's caused by a malfunction in the Windows Desktop.
    Why can't someone with English as their first language, please help me?
    But, regardless, just in case your recommendation(s) had anything to do with anything, and were perhaps creating the problem in the other browser (though I was pretty sure that it had nothing to do with my problem), I made I.E. the default browser; yet, of course, that did NOT correct the problem. Also, when I set I.E. as the default browser, the explorer.exe file crashed and restarted.
    Nevertheless, because I (wrongly) thought that I couldn't uninstall I.E. 11, because somehow I missed the listing for it in Windows Programs and Features, I went to the latter again and found I.E. 11 listed this time, and uninstalled it. After it completed, I rebooted the laptop. Then I went into Windows Update and looked for what version of I.E. it was then going to want me to update to since I.E. 11 was uninstalled.
    I saw that I.E. was taken all the way back to I.E. 8 and had updates for it as well as to update to I.E. 9, so I did the former updates first, rebooted, then updated to I.E. 9 and rebooted again. Then I ran Windows Update again checking for new updates, and found that there was a cumulative security update for I.E. 9, which I installed and then rebooted once again.
    Then, upon checking for new updates in Windows Update again, I found that the option(s) to update to I.E. 10 or 11 were now optional, which they weren't before, and then I updated to I.E. 10 and rebooted once more. Upon Windows restarting, I checked again for new Windows Updates and there were some security updates, so I installed them and restarted the laptop.
    This time upon rebooting, I checked Windows Update for further new updates and there were none; so I'm now completely updated to I.E. 10; but, because going back to I.E. 10 corrected some of the instability with the Windows Desktop, I am ignoring the optional update to I.E. 11, and I am NOT going to update to it again.
    Throughout the update process, upon restarting Windows, I kept starting Firefox to see if the "Save As" window then worked, but throughout the entire update process, as well as when I completed it, I still could not download or save files [because the window still doesn't show where to save the file(s)---please see the Print Screen copy of what it looks like, attached to this message (sorry, but I.E. won't let me browse for the file, and the tab or windows crashes and reloads every time when I click "Browse" to look for the file to attach)].
    So, I decided to try uninstalling Firefox for the fourth time, rebooting and reinstalling it, hoping that might correct he issue this time since I downgraded to I.E. 10, but the "Save As" window still looks the same, and I am still completely unable to save any files or downloads while in Firefox.
    Oh, I also tried resetting all of the Windows Folder Options again to default settings, and reset all of the folders, in case that had anything to do with the problem, but that still did NOT correct the issue either.
    I am now going to try creating a new user account also with Administrator privileges, changing Users, trying to run Firefox in it, and see if the problem with the "Save As" window is still an issue....
    In the new User profile, the situation is even worse. When I try to save any file(s) in Firefox, Firefox crashes (latest version).
    I wrote to Firefox a couple of days ago, but an arrogant "techie" is giving me the run around and is not helping me, and no else is helping with the matter so far.
    Postscript: Now Windows Explorer (the explorer.exe file) that runs the desktop crashed and restarted again twice while I was trying to print a file, and it appears that it won't let me print at all anymore.

  • I can no longer use my ipad to show Netflix on my TV since upgrading to ios7. I don't have Apple TV or airplay icon showing. What can I do to correct this problem?

    I can no longer use my ipad to show Netflix on my TV since upgrading to ios7. I don't have Apple TV or airplay icon showing. What can I do to correct this problem?

    This issue is with Netflix upgrade. I spoke to Netflix and here is the solution. Remove Netflix app from Ipad and reload the app version 5.0.1. This updated version will correct the problem.

  • I keep getting an error message that reads: There is a problems with this windows installer package A program required for this install to complete could not be run. Contact your support personnel or package vendor. How do I correct this problem.

    I keep getting an error message that reads: There is a problems with this windows installer package A program required for this install to complete could not be run. Contact your support personnel or package vendor. How do I correct this problem. HELP !!!!!!!!!!!!!!

    Try the following user tip:
    "There is a problem with this Windows Installer package ..." error messages when installing iTunes for Windows

  • I no longer have sound when playing my clips through adobe premiere elements 12. How to I correct this problem? I have checked all audio levels and there is no mute on etc. I have updated to 12.1. Still no sound.

    I no longer have sound when playing my clips through adobe premiere elements 12. How to I correct this problem? I have checked all audio levels and there is no mute on etc. I updated to 12.1, but still no sound in any clips. Even not on old files which used to work.

    bfun
    What computer operating system is your Premiere Elements 12/12.1 running on? Can we assume that this audio plays back OK
    on the same computer when you are using a computer player independent of Premiere Elements?
    What are the properties of these clips that worked before but do not know with regard to sound
    For now, I will assume that you are working on Windows 7, 8, or 8.1 64 bit.
    Have you checked the Edit Menu/Preferences/Audio Hardware ASIO settings? Do you have any 3rd party audio devices incorporated in your computer environment?
    Please delete the Adobe Premiere Elements Prefs file and, if that does not work, then the whole 12.0 Folder in which the Adobe Premiere Elements Prefs file exists. The Windows 7, 8, or 8.1 64 bit path is
    Local Disk C
    Users
    Owner
    AppData
    Roaming
    Adobe
    Premiere Elements
    12.0
    and, in the 12.0 Folder, is the Adobe Premiere Elements Prefs file that you delete. If that does not work, then delete the whole 12.0 Folder in which the Adobe Premiere Elements Prefs file exists. Make sure that you are working with Folder Option "Show Hidden Files, Folders, and Drives" active so that you can see the complete path cited.
    Do you have installation files or installation disc with the purchased serial number in case we need to resort to uninstall/reinstall?
    We will be watching for your follow up.
    ATR

  • When I hit "send" it refuses, saying the email I just wrote is "spam"; it is NOT, I need it to send, how do I correct this problem?

    Not every time, but often, the program thinks my own email, that I just wrote, is spam. Often it is a reply to an email sent to me and sometimes, if they have an image in the signature line, and I delete their image from my reply, it will send fine (I can leave the rest of what they wrote, and only delete the signature line image). Or sometimes, if I end the first attempt and try a new email or a new reply, then it does work...
    But sometimes, nothing I do will convince the program that my OWN email I wish to send is NOT spam! The person I am sending it to is EXPECTING it and waiting for it!! Why won't it send? Why does it think I am sending spam?!
    I have looked at my server settings, but I have no idea what this would be under.
    How do I correct this? I NEVER send spam, I need this problem solved so that it NEVER happens again. Thank you for any help.

    the exact message that pops up is and alert:
    An error occurred while sending mail. The mail server responded: This message was classified as SPAM and may not be delivered. Please check the message and try again.
    I have tried changing the subject line, retyping the message, opening a new message and sending it that way... nothing is working.
    This is often to people I have already (successfully) sent messages to in the past, people who are already in my address book, and people I am replying to. Also, people I am sending to for the first time, or this is my first reply to an email they have sent to me for the first time. Some emails are personal, some business related.
    This has happened in the past intermittently (usually with replies to an email that has a picture in the original signature line; I delete the picture and then make my reply, usually that corrected the problem) but now it is happening to almost every email I try to send (and deleting the picture, in those emails, no longer works). Since last week, it's gotten worse. I have only been able to send a few emails, most have been refused as "spam". All today every email I have tried to send has been refused.
    I have change no configurations of any kind. I have checked what I can and everything looks fine. help?

  • I have been having this problem since the fourth of this month. I tried to open iTunes and this error came up: "iTunes was not installed correctly. Please reinstall iTunes error 7 windows error 126". If anyone can help I would greatly appreciate it.

    I have been having this problem since the 4th of this month. I tried to open iTunes and this error message came up: "iTunes was not installed correctly. Please reinstall iTunes error 7 windows error 126". There is nothing else that comes up but if anyone can help or know anything about it I will greatly appreciate it.

    Have you tried google for this Error Message...
    http://support.microsoft.com/kb/959077

  • When I try to open itunes it says; This version of itunes has not been correctly localized for this language.  Please use the English version.  How do I fix this problem?

    When I try to open itunes it says; This version of itunes has not been correctly localized for this language.  Please use the English version.  How do I fix this problem?

    Hey KEBENNETT, 
    It sounds like you've restored Windows on your PC and iTunes is no longer opening and running normally. 
    I'd recommend using the instructions found at step 4 and 5 in this article to repair or remove/reinstall your iTunes installation:
    Issues installing iTunes for Windows - Apple Support
    All the best,
    Jeremy 

  • When printing a multi-page document, my computer only prints the first page. How do I correct this problem?

    Using Explorer, I found how to correct this problem by going to "print preview" then selecting an option to print all pages. Firefox does not have the same selection.

    This can happen when Firefox has misread the paper size from the information supplied by Windows. Clearing it can involve finding some obscure settings, but here goes:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste '''print''' and pause while the list is filtered
    (3) For each setting for the problem printer, right-click and Reset it. The fastest way is to right-click with the mouse and then press the r key on the keyboard with your other hand.
    Note: In a couple other threads involving Brother printers, the preference '''printer_printer_name.print_paper_data''' was set to 256 and when the user edited it to 1 that fixed the paper size problem. If you see a 256 there, you can edit the value by doubling-clicking it or using right-click>Modify.

Maybe you are looking for

  • "Unable to capture window image"

    if I select a window to be screenshot, I get this error: Your screen shot can't be saved. Unable to capture window image. (shortcut: cmd-shift-4 and then space) It seems to be new in Lion. Never had that problem before. And regular screenshots seem t

  • Example of 'searching in content/form'

    Does anyone have an example of the functionality 'search'. I want to add this functionality to one of my forms, but I do not know how to realize that. So if anyone has done this before, would he/she share the knowledge with me !! greetings Nico Punte

  • Break table row across multiple frames?

    Hi I would know wether is possible to split a single table row across serverla frames/pages. I´m using InDesign CS5 and when I try to import a big table from word documments (by using de app or by scripting), if a row is bigger than the textFrame, a

  • Website data keeps coming back after resetting mba

    os - yosemite 10.10 safari - version 8 10600.1.25 I remove all website date using safari > preferences > privacy > remove all website data. However after resetting my MBA, i would restart safari and the website data would show thousands of sites stor

  • Getting a Message No Vendor Specified  FromCL_MESSAGE_HELPER=============CP

    Dear All ,                    I am Getting a message No Vendor Specified in a Z transaction . But in Z Transaction I have Specified a Message in the Program . I am attaching the same below   IF SY-SUBRC = 0.     IT_AUFM_TEMP[] = IT_AUFM[].     SORT I