My last question for now!

Hello there, its me again, I managed to do the next two questions on my own!! :-) I'm on the last one now, I have a solution but I feel like I'm missing the point with my code as I have had to retype similar code 3 or more times and some lines aren't even used...but if I follow the instructions they should be there. See what you think....
The aim of this question is to develop the code for a queue which holds int
values. The queue is based on an array and is extensible in that if an item is
added to the queue and the queue is full and an item is added then further space is created within the queue
for the new item. There are 6 methods which need to be provided: head() gives
the int that is the first item in the queue without removing it, tail() gives the int that is the last
item in the queue, add(int) adds an item to the queue, remove() removes the first item
from the queue and returns it, queueLength() gives the number of items in the queue and
display() displays the contents of the queue in order on System.out.
Two constructors are also required, the first IntQueue() sets up a default
queue with 30 elements which, when it becomes full and an item added, adds 5 extra locations to the
end of the queue; the other constructor IntQueue(int,int) sets up a queue
with a length given by its first argument and will add the number of locations
given by its second argument when it is full and an item is added.
The queue should be based on an array with the first element of the array
holding the head of the queue. When an item is removed from the queue the
remainder of the array should be copied forward.
Do not worry about programming errors such as an item being removed from
an empty queue.
We also want you to provide a class Tester for you to test your methods.
public class IntQueue {
private int[] queue;
// Remainder of instance variables
int added =0;
int added2=0;
public IntQueue() {
// Code for default constructor
queue = new int [30];
if (added >= queue.length) {
int[] newArray = new int[queue.length + 5];
System.arraycopy(queue, 0, newArray, 0, queue.length);
queue = newArray;
public IntQueue(int size, int increment){
// Code for two argument constructor
queue = new int [size];
if (added2 >= queue.length) {
int[] newArray2 = new int [queue.length + increment];
System.arraycopy(queue, 0, newArray2, 0, queue.length);
queue = newArray2;
public int head(){
// Code for head
return queue[0];
public int tail(){
// Code for tail
return queue[queue.length];
public int queueLength(){
// Code for queuelength
return queue.length; //String.valueOf(queue.length);
public void add(int item){
// Code for add
if (added >= queue.length) {
int[] newArray = new int[queue.length + 5];
System.arraycopy(queue, 0, newArray, 0, queue.length);
queue = newArray;
queue[added] = item;
added++;
public int remove(){
// Code for remove
int removed = 0;
removed = queue[0];
int[] newArray3 = new int[queue.length - 1];
System.arraycopy(queue, 1, newArray3, 0, newArray3.length);
queue = newArray3;
return removed;
public void display(){
// Code for display
for (int i = 0;i < queue.length;i++){
System.out.println("Array queue["+
String.valueOf(i) + "] = " + String.valueOf(queue));
}

int added =0;
int added2=0;
One error I see straight off is with your instance variables. You haven't made them instance variables! What you have above is what u do when declaring a local variable not an instance.
Try making them instance variables! Same way you made an instance of queue!

Similar Messages

  • Are HDV tapes really necessary? (Last question for now, I promise)

    Do you really need to use them to shoot HD footage? Is there an obvious benefit to them or is this another marketing thing?

    no it is not needed
    but they are "better" for preventing dropouts which will REALLY mess ya up in HDV (up to a half second lost)
    yes it is mostly marketing
    try PANASOINC PRO or MASTER tapes (they are actually cheaper in most cases but much reliable then most consumer tapes)
    DAVE

  • HELP-LAST-QUESTION - FOR - NAT

    Dear All,
    I was reading my NAT Design Paper, because I am going to Implement NAT in My Company.
    Now, I want to ask you for only the Process of Static NAT , to allow External Users ? on internet side ? to ? access a specific server inside my LAN.
    Which is the things that determine this NAT will Work from External to Internal , or Internal to External ?
    Please answer the 3 questions .
    1- Is it the Route command that I configured on the router it self , only ?
    Or,
    2- Is it the Route Command + NAT Table which is configured on the Router it self ?
    Because As far as I know, I understood the following:-
    To configure the NAT, I have to:-
    1- determine which INTERFACE will act as IP NAT OUTSIDE , usually the one which have the IP from the ISP Side.
    2- Determine which INTERFACE will act as IP NAT INSIDE , usually the one which have the IP from the Private LAN.
    3- Determine the NAT statement , if its STATIC / dynamic /overloading .
    4- Determine the Route command .
    3- Here is Step 4 , I can make rule to forward every thing from INTERNAL to EXTERNAL or from EXTERNAL to INTERNAL , according to My Design Requirements.
    So, from the NAT Command + Route Command , I can make the NAT From External to Internal , or, from Internal to External . is that correct ?

    Hi!
    Good Day! I believe this would best answer your questions. Please check this link:
    http://www.cisco.com/en/US/products/sw/iosswrel/ps1839/products_feature_guide09186a0080087bae.html
    To verify, you can use "show ip nat translations" to display all ip address translations.
    HTH! Regards,
    Albert

  • Last question for today - how to draw with API circle of N pixels radius

    Hi,
    While I'm bit of exhausted while fighting with those paths movement (see my other thread in this forum) - I'd like to ask maybe someone has code snippet, which shows how to draw a circle of N pixels/N mm/inches radius?
    There is one helper function for that inside SDK samples:
    PDEPath DrawCurve(ASFixed x, ASFixed y, ASFixed x1, ASFixed y1, ASFixed x2, ASFixed y2, ASFixed x3, ASFixed y3, int lineWidth, int r, int g, int b)
    but I'm just out of my mind for today what parameters should be provided and how many calls of it I should write.
    Any help would be appreciated.

    You call it four times...
    Here is a snippet that explains the math...
    /* 4/3 * (1-cos 45)/sin 45 = 4/3 * sqrt(2) - 1 */
    #define ARC_MAGIC ((ASFixed) 0.552284749)
    #define PI ((ASFixed)3.141592654)
    void DrawCircle( ASFixed inCenterX, ASFixed inCenterY, ASFixed inRadius )
    /* draw four Bezier curves to approximate a circle */
    MoveTo( inCenterX + inRadius, inCenterY );
    CurveTo( inCenterX + inRadius, inCenterY + inRadius*ARC_MAGIC,
    inCenterX + inRadius*ARC_MAGIC, inCenterY + inRadius,
    inCenterX, inCenterY + inRadius );
    CurveTo( inCenterX - inRadius*ARC_MAGIC, inCenterY + inRadius,
    inCenterX - inRadius, inCenterY + inRadius*ARC_MAGIC,
    inCenterX - inRadius, inCenterY );
    CurveTo( inCenterX - inRadius, inCenterY - inRadius*ARC_MAGIC,
    inCenterX - inRadius*ARC_MAGIC, inCenterY - inRadius,
    inCenterX, inCenterY - inRadius );
    CurveTo( inCenterX + inRadius*ARC_MAGIC, inCenterY - inRadius,
    inCenterX + inRadius, inCenterY - inRadius*ARC_MAGIC,
    inCenterX + inRadius, inCenterY );
    Close();

  • Last question for the day - Music Video

    Hi,
    I have been asked by a friend to do their music video for them. I understand while shooting they will be playing to the original recording but after a day of shooting and im back at my computer what is the best way to syc my clips to the master audio track? Is there a tutorial available on music video creating? I know I could sit there and bit by bit move the clip to match however I am hoping there is a tutorial on it some place on the net.
    Thanks

    Hi
    Me just thinking
    I would
    • Make several full song recordings with my Camera (close-ups, full size etc.)
    or use several Cameras (5 to 10 recordings)
    Put the best Audio-uptake as a master Audio then add video clips to do the visual
    part as rythmic and paced fast/slow enough to reflect the "Air" of the lyrics.
    Know what I'm taking about - NO Not at all - just speculating.
    (With several Cameras - all recording non-stop - this would be much easier in
    FinalCut Pro and the MultiCamera function.)
    Yours Bengt W

  • Basic questions for a self-taught re: HDV for SD HDV (yes again)

    ok - like many others posting on this topic, I am apologising for going over what seems to be one of the most covered topics out there, that still isn't clear!
    I am trying to teach myself DVD SP4 in the same way I did with FCP5 (trial, error and lots of forum searching). I am by no means a pro on FCP - but have certainly got enough understanding of it to have cobbled together 7 23 minutes episodes to broadcast! I have gone thought the DVD SP4 Manual and forums and lots of it just makes my brain ache - what mostly lets down my understanding are formats/compression/codecs.
    So - my main questions (for now....)
    -In DVD SP I couldn't import my QT movie into my assets list as it was an "incompatible format" - is this because it was HDV to a SD DVD Project? Doesn't the process of DVD SP encoding it as Mpeg 2 make is SD anyway?
    -I read a post from someone in a similar situation, who advised exporting a HDV sequence as Uncompressed 8 Bit, and bringing that to DVD SP. So am doing that now (6 hours or so for a 23" sequence) and am hoping it gives a great looking picture, but I have seen from its preview icon that its a 720 x 576 frame - why is it not exporting in 16:9? or will it squeeze that down to normal once it's in DVD SP?
    Really appreciate any understand you can help me with.
    cheers
    Hugh

    Hughey wrote:
    Going back to my original questions - could the problem be a HD file in an SD project?
    No. If you followed the workflow process from the above post you would have a SD mv2 file. The file should be playable in Quicktime and it should be 16:9.
    EDIT: Yes. Reading back on your OP this question ->
    In DVD SP I couldn't import my QT movie into my assets list as it was an "incompatible format" - is >this because it was HDV to a SD DVD Project? Doesn't the process of DVD SP encoding it as Mpeg 2 >make is SD anyway?
    I believe that importing a HDV file into a SD project would give you that error but if you follow the above steps and import the mv2, AC3 files you should not get that error.
    The reason you got three files is because that is how the preset group is made up. To be completely truthful I duplicated that preset, deleted the AIFF part and renamed the group. I now use that as my default settings when I bring any asset into Compressor.
    As far as bring video assets (quicktime SD/HD, or other) into DVDSP in general you can do this but, what is happing is that in the background DVDSP is going through the steps from my above post and creating the mv2, AIFF, AC3 files for you (based on your preference setting in DVDSP) and then replacing the video files you brought in with the compressed files.
    Can you play the mv2 file in quicktime? If not then something else must be going wrong.

  • Question for CL Forum Ad

    I have been reading through this forum and there seems to be no shortage of upset customers. They all seems to be asking the same questions over and over again, and the only answer given is, "I'll post more information when I get it".
    Now, I'm not a real tech savvy guy, but why is it not possible, to walk over to the desk of the head developer, and say, "Hey Steve, can you tell me why the new drivers are the same as the beta ones?"
    And then walk back to your PC and type the answer here. I mean lets be honest, unless you are sending messages via snail mail, I don't understand why this is so hard to do. I suspect you HAVE the answers, but the big cheese at CL has told you to simply deflect the questions for now.
    What I am trying to say is that by you saying you'll post information when you get it, does nothing but make your company look completely rag tag. It gives the impression that everyone just works part time from home, and they only meet every other Saturday for a softball game. There is no official statements from CL, you guys don't have any answers, no one knows when anything is being released or what it'll have in it...it just seems like the company is in shambles.
    And this brings me to my second question. While you're slow to respond to questions about why things aren't working and such, but you are quicker than a fat man chasing a rolling donut down the street when someone advertises another brand, so my question is what do YOU recommend we do?
    Can you suggest some solutions for all of the people who bought CL cards and have no working drivers? I would really appreciate if you didn't simply ignore, or skirt around this question.
    I think it's time you threw us a bone here, if you're not going to give us any information, then at least give us some other alternati'ves.

    Dude, honestly, I could care less what happened 0 years ago. I have said it before and I'll say it again for you, just because this type of thing keeps happening doesn't mean it's right.
    When I buy a product from a company I don't do it thinking, "Hey, maybe if I buy this product then the $200 will help them become the best company in the world, and I don't care if it works or not, I just like the feeling of supporting companies in the hopes they'll do well!"
    I buy products, and I expect them to work.
    Regardless, if you had actually read my post, you would see that I'm not asking when the drivers will be out, or why they aren't... I am asking why this "world leader" in sound cards can't communicate effecti'vely with it's customers? I am asking why the Admins keep saying the same old mumbo jumbo, and expect us to buy that they can't actually just go talk to the people in charge.
    I am also asking if they can't tell me that information, then help me find some alternati'ves.
    So, why don't you paypal me a few hundred dollars for a new sound card. You seem to have no problem sitting there giving your sound card "high fi'ves" and talking to it in a sweet voice, "Don't worry little sound card, I know you have amazing potential, I won't give up on you!"
    "Do you remember the old days of Windows 2000?" We then cut to a montage of you running through fields of flowers hugging your sound card and a copy of Windows 2000. You shake your fingers at them and say, "Not yet little guys, soon we'll all be together in harmony, we just have to wait!!"

  • I have install last update for i pod(ios5) but during installation there was one problem....i have restore my ipod and now i have lost all my buyed music!!Is not possible download it....?What are the details, including any error messages, related to your

    I have install last update for i pod(ios5) but during installation there was one problem....i have restore my ipod and now i have lost all my buyed music!!Is not possible download it....?What are the details, including any error messages, related to your question?

    Have you not got the music on your computer and/or on backups on, for example, external drives or CDs/DVDs ?

  • TS2988 I had to reset my phone and I only have one of my ringtones I had 4.. Why'd it delete 3 and not the last one and now I can't get em back without paying for them again!!! What the **** is up with that??

    I had to reset my phone and I only have one of my ringtones I had 4.. Why'd it delete 3 and not the last one and now I can't get em back without paying for them again!!! What the **** is up with that??

    Yup, your question and Diane's answer helped me also. Tho' I had had problems before getting into the iTunes store I always managed to find a way. Today they had me blocked cold with the "Update to 10" advert no matter what I did. Other questioners are being told, incorrectly as it turns out, that they have to update their OS to accomodate iTunes 10 and upgrade to iTunes 10. I did the download which did not take up much more room on my crowded old hard drive and now I'm back in business.

  • Thanks for the idea. One last question..

    Thanks for the replies, setting it to passive seemed to work
    as I can now upload to my host. Just one last question, I've
    searched the video knowledge base looking for a video on how to use
    the 'Starter Pages' within Dreamweaver to no avail. When I try I
    always get the same message: 'Dreamweaver stores templates in the
    root folder of a site, but there are no sites defined. Please add a
    site.' I have my site all layed out in Dreamweavers FTP, I can
    upload and download with it and still Dreamweaver gives me this.
    Any ideas?
    Thanks once again all

    Using FTP & RDS Server for your site means that you will
    not be able to use
    DW's Templates or Library items. It's usually a very bad
    idea, to boot.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "John Waller" <[email protected]>
    wrote in message
    news:g1a9mi$qtn$[email protected]..
    > F1 Dreamweaver Help files
    >
    > Working with Dreamweaver Sites > Setting up a
    Dreamweaver site
    >
    > --
    > Regards
    >
    > John Waller

  • HT201210 After asking a question last week, I now get scores of emails every day. I turned off the radio buttons on " notify me by email " respectfully please help

    After asking a question to the community last week, It now get scores of emails now with questions . I had marked the radio buttons to be notified but
    Later found them, and un clicked them all. Also I might have been hacked, because I was charged yesterday with an App, that I did not order!!!
    I only know that, because I get an instant message from my bank by phone, when I spend any money. I am worried.
    Bambi

    Hello Dorothea5916,
    It sounds like you changed your forum account preferences and now they have changed back, and you have an unauthorized purchase on your iTunes Store account and have concerns about your account security. I recommend first changing your Apple ID password with this article:
    Apple ID: Changing your password
    http://support.apple.com/kb/ht5624
    Go to My Apple ID (appleid.apple.com).
    Click “Manage your Apple ID” and sign in.
    If you have two-step verification turned on, you'll be asked to send a verification code to the trusted device associated with your Apple ID. If you're unable to receive messages at your trusted device, follow the guidelines for what to do if you can't sign in with two-step verification.
    Click "Password and Security".
    In the "Choose a new password" section, click Change Password.
    Enter your old password, then enter a new password and confirm the new password. Click Save when done.
    The next time you use an Apple feature or service that uses Apple ID, you'll be asked to sign in with your new Apple ID password
    You should also report an issue with the purchase to the iTunes Store support directly with the following article:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBooks Store purchase
    http://support.apple.com/kb/ht1933
    To enhance security for your account you may want to look into Two-Step Verification to help prevent unauthorized access to your account:
    Apple ID: Frequently asked questions about two-step verification for Apple ID
    http://support.apple.com/kb/ht5570
    Thank you for using Apple Support Communities.
    Cheers,
    Sterling

  • Please read my question carefully, this is, I think, a question for the experts. It's not the usual name change question.   When I setup my new MacBook Pro, something slipped by me and my computer was named First-Lasts-MacBook-Pro (using my real first and

    Please read my question carefully, this is, I think, a question for the experts. It's not the usual name change question.
    When I setup my new MacBook Pro, something slipped by me and my computer was named First-Lasts-MacBook-Pro (using my real first and last name).
    I changed the computer name in Preferences/Sharing to a new name and Preferences/Accounts to just be Mike. I can right click on my account name, choose advanced, and see that everything looks right.
    However, If I do a scan of my network with my iPhone using the free version of IP Scanner, it lists my computer as First-Lasts-MacBook-Pro! And it lists the user as First-Last.
    So even though another Mac just sees my new computer name, and my home folder is Mike, somewhere in the system the original setup with my full name is still stored. And it's available on a network scan. So my full name might show up at a coffee shop.
    Can I fully change the name without doing a complete re-install of Lion and all my apps?

    One thought... you said the iPhone displayed your computer's old name? I think that you must have used the iPhone with this computer before you changed the name. So no one else's iPhone should display your full name unless that iPhone had previously connected to your Mac. For example, I did this exact same change, and I use the Keynote Remote app to connect with my MacBook Pro. It would no longer link with my MacBook Pro under the old name, and I found that I had to unlink and then create a new link under the new name. So the answer to your question is, there is nothing you need to do on the Mac, but rather the phone, and no other phone will display your full name.

  • Got a question for all you peeps dos anyone know about i phones i have a i phone 3gs which i got unlocked i did a master reset or summin and just had a pic of apple so i plugged it in i tunes downloaded and it now says no service at the top of phone and i

    got a question for all you peeps
    dos anyone know about i phones i have a i phone 3gs which i got unlocked i did a master reset or summin and just had a pic of apple so i plugged it in i tunes downloaded and it now says no service at the top of phone and i tunes says invalid sim i put the correct sim in it used to be locked too and still says same pls any one with ideas?

    hi sorry what happoned is that ages ago i brought a i phone 3gs on 02 network i went to a sml phone shop and payed for them to unlock it. it has been fine till yesterday when i went to reset it from the phone it then turned off and came back on just just an image of a apple for about an hour so i connected to i tunes and it said downloading software after another hr it had finished but then i tunes said in had to insert a sim so i had to un plug the phone from laptop while i did this i put my orange sim in and the i phone said where do i live and had to connect to a internet connection but all the time saying no service where the signal bar is and then says activating i phone it took a few min and said couldnt finish it bec of the signal and to connect it to i tunes to do it so i connected it to itunes and i tunes just keeps saying invalid sim so i took my orange sim out and put a 02 sim in and is still saying invalid sim on itunes?

  • When trying to download apps on my new iPad I keep getting prompted to update my security questions for my safety. When I choose this option it freezes and won't load the questions, however, when I hit not now it won't let me download. What do I do?

    When trying to download apps on my new iPad I keep getting prompted to update my security questions for my safety. When I choose this option it freezes and won't load the questions, however, when I hit not now it won't let me download. What do I do?

    Reboot your iPad and then see if you can set the security questions.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • HT1338 I'm running MacOS 10.7.5 with all updates and did an update last night for aperture and now aperture doesn't open.  What's Zup?

    I'm running MacOS 10.7.5 with all updates and did an update last night for aperture and now aperture doesn't open.  What's Zup?  Help!

    Also when I do the system update it's not giving me an update for the latest Snow Leopard. I never knew that was available until I started looking around this site and it seems that since I have the internal dual core I should be able to update to mountian lion...is this correct? Will someone please help me and walk me through this. I love my mac I want to have it running like it should be.

Maybe you are looking for

  • IPhone 3Gs OS 4.0.2 problems!!!

    Hi, Thought my iPhone was the dogs danglies for 13 months until I made the biggest mistake ever of updating to the new OS4, how can this ruin the phone so much?? My biggest problem is now the loud speaker is very very faint, at first I thought it was

  • Solved WiFi issue - Hope it works for you. If not, sorry.

    Hey, I know about your problem. I've been a Windows person for fifteen years and bought a MacBook Pro about eight hours ago and same problem. Been researching it for eight hours and got it to work. I don't know much, but you can try this and maybe it

  • COMMIT

    Hi, I want to do a test, I loaded a table in DB2 from another table with 600,000 records, The problem is that there is many records and an error occurs, error+ --> Virtual storage or database resource is not available How it is possible to complete t

  • Ms-6367 (nforce) information please

    I am going to next buy the MSI 6367 Nforce 420D motherboard in a store by Internet. I wanted to know if MSI 6367 includes the TV-Out card (S-Video) and SPDIF bracket, or are component optional. I have looked for in MSI Web page but I have not found a

  • How to upload an html file using jsp and jdbc

    Hi, im trying to upload an html page using JSP and jdbc. but of no success. my aim is to keep some important html pages in the database.the file size can vary.the file has to be selected from a local machine (through the browser) and uploaded to a re