Quick advice needed...

I have a collection of sorting algorithms which are all implemented. All of these classes have the method 'print' and 'randomise' (generates a random array of integers). This is obviously redundant, writing these two methods in every class. Should i make a class for these two methods and let every other class extend it. Or should i use an interface? Which then i will implement is every class. I'm not too sure, it would be great if i had some advice. Any help is appreciated.
Thanks in advance.

To me, it doesn't sound like the job of a sorting algorithm is to either generate random numbers or print out anything. I think you have incorrectly factored your application. The sorting algorithm should sort, period. It's up to the code that uses the sorting algorithm to provide the data - whether it's random or read from a file, etc... TThe sorting algorithm shouldn't know or care how the data was generated. And as well, once the data is sorted, the sorting algorithm shouldn't print it out: that's for the code using the sorting algorithm to handle. That code may print out the data or go on to use the data further. Again, the sorting algorithm shouldn't know or care in the least about that.

Similar Messages

  • Quick advice needed on Observer and Observable...

    Ok at the moment i have about 10 sorting algorithms in 10 classes. They all extend another class which includes methods like print, randomise, user input etc etc which all sorting classes use. So basically my sorting classes only sort and nothing more is done in those classes.
    Now what i want to do is have some statistics on a GUI. This will include copy coperations, compare operations and total operations. I will obviously need to input where these operations occur for each sorting class. I want the GUI to be updated each time an operation happens. All my sorts run in a thread, i did this so i can choose the speed of the sort with a JSlider.
    My question is, will i need to be using the Observer and Observable interface? If so, can i have some advice into how i would structure this. If not, then how else can i do a statistics class. I tried a way without this approach, but it didn't seem too OO friendly. Any help is appreciated.
    Thanks in advance.

    I'm not a GUI guy and this is definitely not the best way to do it - but you could probably call an update method after each calculation or whatever. Make a static method that has a reference to your GUI form.
    This is definitely not an elegant solution - but I think it's explicit and readable, and that can be more valuable than elegance.

  • (off topic) Quick advice needed RE: publishing

    (sorry for the waaayyy off-topic post, but I'm sure some of you gurus would know the answer to this. I'm sort of in 'freak-out' mode right now.)
    So my CD artwork is finalized, and slated to go to press this Friday. I just realized that, though I am registered with BMI, I put no mention of that on the disc or in the liner notes. DOH!
    Do I need to? If so, is simply putting "Copyright 2006 [band name here], BMI" sufficient? Or do I need a 'music company' name (in other words, not the band name).
    thanks for any advice !

    Songs are tracked and money is distributed by song title, writer and publisher name. Don't make it hard for people to pay you. Make sure you get your publisher info on there.

  • Photoshop Elements 8 advice needed please

    Hello!
    I received PSE8 for Christmas and have Never used one of these programs before!  I noticed it does not come with a manual of any sort and did find a few books on amazon and was wondering if any of you "experienced" users could recommend one to me!
    Was looking at either the "Dummies" book for PSE8 or the "Missing Manual" series.
    Any advice is appreciated!  I learn quick but need good clean explanations!
    Thanks!
    Carrie

    I used PE The Missing Manual by Barbara Brundage when I started out with an earlier version of the program. The chapters are well written and illustrated. It is a quality product and should serve you well. Barbara moderates this board and is generous with her advice. I have no commercial connection with the author or with the publisher.

  • Advice needed on buying iphone as gift

    I went to apple store, they do not want to sell iphone to me unless I sign AT&T 2 years plan. I thought AT&T has locked the phone and users must subscribe in order to use it. Why Apple store still not allow me to buy?
    Please advice, if I want to buy online iphone for my brother, do I or my brother have obligation to sign out AT&T plan?
    One more advice needed, I found the shipment takes weeks, do I have option to arrange for self-collection?
    My brother birthday is coming soon, I need above advice urgently.
    Thank you very much

    Tamara wrote:
    I'm guessing English is not your first language. It's possible that you misunderstood them. Apple Store employees won't refuse to sell you an iPhone and you don't have to sign up for service in the store.
    Well that's not entirely true.
    Apple Stores have been instructed not to sell you an iPhone if any of the following is true:
    • You state that you will not be signing up with AT&T.
    • You do not have an ID from a US state, also indicating you will not be activating with AT&T
    • You do not have a credit card
    For example, I've seen US Apple Store managers refuse to sell iPhones to European residents because of the AT&T lock-in.

  • Video intensive work on Mac Pro? Advice Needed

    Hi everyone,
    I've been originally saving up for a while now for an iMac 24" as it offers the best specification price wise. But now I leaning on the Mac Pro and therefore need some advice.
    I know that there are alot of posts on advice - need to buy mac etc. so therfore I would really appreciate if I am afforded some help.
    I am mostly going to do ALOT of video encoding (via handbrake) and I am looking for the best configuration available to achieve lowest waiting time.

    I think you should go back and look at the other threads with advice, your budget. There is "ideal" and "affordable."
    Will it pay for itself in 24 months so you can afford the next revision at that time?
    Start with an 8-Core 3GHz.
    Add a Port Multiplier controller and two drive cases, 5 drives each, nearly 400MB/sec RAID.
    Throw in 8GB RAM.
    Add in costs for software upgrades, two sets of backups, four internal 500GB drives.
    Seagate has 750GB, as does WD. Hitachi has their $450 1000GB monster.
    Give yourself time to build, test, and optimize your setup, and expect to change it over time as you learn more.
    Can't afford that? then trim the 8-core. But Apple has shown how efficient next generation applications already are for video when it comes to 3GHz 8-core Mac Pro.

  • Had to have a rebuild of my laptop....advice needed!

    Had to have a rebuild of my laptop....have now lost all my music from my itunes, but I can't transfer back on from my ipod. Also had to register my laptop (same) as another computers, so now no music showing as purchased, though I have. Also have hours of uploaded music from my own purchased, legitimate CDs, but won't transfer from ipod...it says it will erase. So very frustrated....thanks mr technician!    PLEASE  ....help, advice needed!

    I believe that if you do a clean reinstall from your HD's recovery sector (D) or Recovery disks, the hard drive sector C is wiped clean. Everything goes, apps, data, address books, music, pix, viruses
    Is that what you did?

  • I am using InDesign CS5. I have a body of text which is ranged left with tabbed indents. My client now wants the copy to be justifed, keeping the tabbed indents. Help and advice needed please!

    I am using InDesign CS5. I have a body of text which is ranged left with tabbed indents. My client now wants the copy to be justifed, keeping the tabbed indents. Help and advice needed please!

    Hi
    That screen grab helps a lot. There’s a much easier way of doing what you’re doing.
    Remove all your tabs and set the text in justified paragraphs.
    I’ve typed in dummy text in the example I made below, but after “19.1” put in a space and put your blinking cursor after the space and before the ’N’ of ‘Notices'.
    Then hold down the Command key and hit Backspace (on Mac at least - it’s the key between the Inverted commas/ apostrophe key and the return key).
    The text will jump into place the way you want it to.
    Hope that helps
    Paul
    PS You can set a tab, instead of using a space, in the description I gave above. So, after 19.1 or 19.2 or 19.185 etc etc insert a tab, then hit the Command Backspace after every paragraph number and they'll all line up exactly together. You'll find that editing text within the paragraphs
    after you've set it will be LOADS easier this way.
    You can put the tab anywhere you want it to be using 'Command-ShiftT' and putting a 'left align' tab just after the number. Just type the Command Backspace after the paragraph number and it'll work

  • After upgrading my i tuns i cant open says quick time needs to be 7.5.5 or more wth

    after upgrading my i tuns i cant open says quick time needs to be 7.5.5 or more wth

    Hello amyluvscarolyn
    Depending on what version of Mac OS X you are running, you may have a newer version. If you are needing QuickTime 7, then check out the article below for the correct links to download for your system.
    Installing QuickTime Player 7
    http://support.apple.com/kb/HT3678
    Regards,
    -Norm G.

  • MOVED: Various advice needed to overclock cpu using my MSI k8n platinum sli

    This topic has been moved to Overclockers & Modding Corner.
    Various advice needed to overclock cpu using my MSI k8n platinum sli

    what HSF for cpu/ cooling for the case do you use? And also, where are the flashing lights?

  • Quick time advice needed

    first of all where can i get quick time 7 for mac every time i go on the apple website it keeps giving me the windows installer where the **** is the mac quick time installer.
    i am currently using os x 10.4.9 on a d,a with upgraded processors duel 1 ghz. but my quick time progrgram keeps crashing every time i try to watch an oldish quicktime file i have i keep getting error messages from a fire wire external hard drive

    "i get lots of errors going off some times it works other times it shows no sound or bleeping noises or error messages im wondering if the hard drive as a problem with it"
    Are you talking about your Software Update control panel? If so, then you need to cross-post in the Forums of whichever model Mac you have & the Mac OS X v10.4 Tiger Forums
    You will also need to advise exactly what those errors stated so that the knowledgeable users in the above forums can properly advise you on troubleshooting solutions.
    In the mean time the following Knowledge Base Article may be of some use:
    http://docs.info.apple.com/article.html?artnum=106695 Troubleshooting Automatic Software Update in Mac OS X
    Your system info confirms you are only using OS 10.4 which is currently outdated & not compatible w/the currentl version of QuickTime.
    You need to update your OS & possibly other things for your model Mac.

  • When making a circle, illustrator automaticly makes lots and lots of more circles... How to resolve this problem? Really need quick advice!!

    Hi there,
    I have used illustrator now for a long period of time. Recently I purchased Adobe CC. Had no problems with it untill now.
    It's like this. Whenever I try to make a circle (or, square, line or other forms) Illustrator makes lots and lots of more circles within it.
    From the moment I click on the page untill I release my mouse, it keeps making circles. (see enclosed picture)
    I have really no idea whatsoever how to undo this. I have used Illiustrator CC before for another project, and it worked fine. Now however, it doesn't.
    Can anyone help me out here? I have payed projects to deliver, and I really need this to work really soon...
    Thnx for your help!
    btw, I work on a PC with Windows 8. (don't really think it's relevant, but still..)

    Thnx!
    I didn't know that could cause it. Which is actually weird since I've recently bought a new laptop. >,<U
    Thnx for your help!

  • In need of quick advice!

    Alright, I just bought a 16 gb nano from Best Buy. Since getting home I've noticed that there are some scratches on the case, and doesn't Apple usually ship the ipods with the lock on? Because the one I bought has it off. Am I being paranoid, or would it seem like I got one that was used and brought back? The sticker at the top looks like its on well, but it looks slightly out of place... So my questions are, did I get a returned ipod, and if so, should I bring it back, or try it out and see how things go?

    You said the case is scratched. Well being a former best buy employer and also dealing with ipods on a daily basis. The cases can be scratched. They aren't always wrapped one by one etc. Most times they are shipped to best buy stores (from best buy warehouses) in plastic crates with also other products most times with accessories (headphones, cases, etc). so cases can and will be scratched a lil bit. and doesnt mean they wont work. If you feel weird about the product. Return it! Thats part of a Customers Right. and Part of "Lemon" product rule. (if a product is messed up from warehouse or just flat out crap, its up to the store to take it back from you (and return to the manufacture)and give you another product if your wanting another.
    However if the ipod it self seems out of place even if the Seal (tape) seemed to be fine. Go to best buy.
    and here are some tips to make your visit quicker and less stressful.
    As you enter let the (person in Yellow in the front) place a sticker on the product. (tell them your are there to question/return) (they will tell you to go to the Customer Service Desk).
    However just Go right to best buy MOBILE section (where ipods are).
    Get a Mobile employee which wont always be there lol. but anyways. tell them Hey look this ipod i just got, i feel may have been messed up etc..show them the product, and let them know that though its the case, thats scratched but you don't want to take a chance on it have being damaged in shipping etc....(however, when you walk in the store, and it looks very slow, (not many customers (mainly you can tell by, if the employees are bored and chattin) lol..you can just go ahead and ask (person in the yellow) you want to speak to a manager (however, it can tell a while for one to get to you).
    They will then find out if they have more of that color etc still in stock. then the will walk you up to customer service with the product (its a safety thing they do) incase someone wants to run out with a ipod lol. then they can help you out from there with an exchange. by the way you may want to get a Product Replacement plan with BBY they are a few bucks. but I tell you. they really do work and pay for them selves. b/c if ur ipod is damaged (other than not being dropped, thrown, water on them etc). they will quickly exchange the product for you.
    Now these are just some tips. how to deal with best buy and doing an exchange.
    if you go to Customer Service First. just notice, those employees can't do anything, other than to tell you to go talk to one of the MOBILE experts. (and some customer service people, will tell you "yeah you can't return that". ) and then once they help you, then you have to go back to customer service and wait in line to exchange or return etc.

  • Need quick advice: amex gold app

    so i got an online offer for the 50000 points w/ amex gold. in the last two weeks i applied and was approved for cards w/ discover and citi. was satisfied and not planning to apply for anything else. until i got this offer. should i apply for the amex given the great offer or pass? also, i'm an AU on my wifes blue cash preferred amex. the amex app for the gold card say if amex finds that you already have an amex account, you might night get the offer. does that extend to AUs? thanks in advance!

    rabbitwhole wrote:
    so i got an online offer for the 50000 points w/ amex gold. in the last two weeks i applied and was approved for cards w/ discover and citi. was satisfied and not planning to apply for anything else. until i got this offer. should i apply for the amex given the great offer or pass? also, i'm an AU on my wifes blue cash preferred amex. the amex app for the gold card say if amex finds that you already have an amex account, you might night get the offer. does that extend to AUs? thanks in advance!If you're approved then you'll get the offer regardless of whether you are an AU or even have a card yourself.  If you're interested in the card, go ahead and apply.  Let us know the results.

  • Need some quick advice on a restore with Time Machine

    I have just had my MacBook Pro wiped and reinstalled as there was a problem with the way it would 'see' the battery (there was an intermittent fault).
    I think that this has been solved now. So now I want to reinstall the whole Time Machine backup = but NOT the faulty base settings (the Operating system, etc). Everything - applications, folders, settings , files etc. How do I do this?

    I have just had my MacBook Pro wiped and reinstalled as there was a problem with the way it would 'see' the battery (there was an intermittent fault).
    I think that this has been solved now. So now I want to reinstall the whole Time Machine backup = but NOT the faulty base settings (the Operating system, etc). Everything - applications, folders, settings , files etc. How do I do this?

Maybe you are looking for

  • Standard vs Professional  - forms/javascript

    I need the ability to add/edit from fields, add submit buttons, and add Adobe javascript to PDF documents. Can this be done in Standard or do I need Professional? Thanks. kpg

  • Problem with printing from file to printer

    I've been having problems printing more than one page of text from a file to a specified printer in addition to the fact that the number of pages the print dialog says are to be printed is always 9999! I have tried overriding functions from Pageable

  • How do you know when a movie rented on apple tv is ready to view.

    I rented the hd version of a movie yesterday. I am not able to find the movie on apple tv (rented direct from apple tv) how do I locate the movie? I know this sounds dumb but I cannot find it and when I go to iTunes on apple tv it tells me I have alr

  • Problem in Select Statment

    I have two tables <b>TAB1</b> <u>F1</u>     <u>F2</u> A1     AA A2     AA A3     BB A4     AA A5     AA <b>TAB2</b> <u>F1</u>     <u>F2</u>     <u>F3</u> B1     AA     D1 B2     BB     D1 B3     CC     D1 B4     AA     D2 B5     AA     D3 B6     BB  

  • Best for Backing Up

    Ok, I am guilty of usually not backing up my computer and I feel I have been lucky so far. I was going to wait for Time Machine but maybe I should just start taking care of things now instead of waiting. I need some advice on the best way to make a b