Having hard time getting this to work.

Hi
I have been working on this for several hours now and not having much luck. I think im not understanding the relationship between the two classes properly. Also there is a GUI that goes with it but it only so fay has the code to construct the GUI. My problem is getting these two classes to compile, then mabe i can move on to finishing the GUI. If you need the GUI then i can post it.
If you could, please take a look at these two classes that im having trouble with, where am i going wrong.......
import java.util.*;
     public class ShoppingCart     {
private Product[] shoppingcart;
private static int count;
public void shoppingCart()     {
shoppingcart = new Product[50];
     count = 0;
public void addProduct(String name, double price, int quantity) {
boolean found = false;
int i = 0;
while(i < count)
if(shoppingcart.getName().equals(name)) //tests for existing entry.
found = true;
break; // break form loop if true.
i++;
     // adds retrieves corresponding number for entry.
if(found == true)
shoppingcart[i].setPrice(price);
// adds new entry.
else {
if(count < shoppingcart.length)     {
shoppingcart[count++] = new Product(name, price, quantity);
else {
Product[] temp = new Product[shoppingcart.length*2];
for (int j = 0; j < shoppingcart.length; i++)
temp[j] = shoppingcart[j];                                   
temp[count++] = new Product(name, price, quantity);
shoppingcart = temp;
          public String findProduct(String name)     {
for (int i = 0; i < count ; i++)
if(shoppingcart[i].getName().equals(name))
return shoppingcart[i];
return "Not found.";
I think i will post the other class below.....

This is the second class.
Explanation. With a working GUI this program will add and retrieve different products, two events are required, add/modify and search. new products are added to an array with three parameters name, price and quantity. These product need to be able to be called up and stored into a text area displaying name, price and quantity.
Any help is appreciated.
public class Product {
private String name;
private double price;
private int quantity;
public Product(String name, double price, int quantity)     {
          this.name = name;
               //price = 0.00;
               quantity = 0;
               //this.name = name;
this.price = price;
public String getName()     {
return name;
public double getPrice()     {
return price;
public int getQuantity()     {
return quantity;
          public void setName(String name)     {
          name = name;
          public void setPrice(double price)     {
          //price = price;
          public void setQuantity(int quantity)     {
          quantity = quantity;
}

Similar Messages

  • Convert SSRS dropdown MDX query to INNER JOIN w/ NONEMPTY? Having hard time with this.

    I'm having an incredibly hard time with this, mostly because I'm very new with MDX.
    I created a simple report (with AdventureWorksDW) whose datasource is an SSAS cube. I select a datekey from the dropdown menu, and the report displays [Measures].[Order Quantity] for that day.
    The problem is that the dropdown displays every single value from the dimdate dimension. DimDate goes from 20050101 to 20201231, so the dropdown is very long.
    How can I alter the SSRS-generated MDX so that it does an INNER JOIN with Fact table and only the dates shown in the dropdown are the ones where there's data in the Fact table?
    Currently, the fact table only has 2 days of data (20141015, 20141016), which means that the dropdown should only display those two dates. I'm including the generated code MDX that populates the dropdown menu:
    WITH MEMBER [Measures].[ParameterCaption] AS
    [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION
    MEMBER [Measures].[ParameterValue] AS
    [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME
    MEMBER [Measures].[ParameterLevel] AS
    [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption],
    [Measures].[ParameterValue], [Measures].[ParameterLevel]}
    ON COLUMNS , [Dim Date].[Date Key].ALLMEMBERS ON ROWS
    FROM [Adventure Works cube]
    Any help is appreciated.
    VM

    Hi vmhatup,
    you can get rid of blank data using nonempty function and get rid of negative values using filter function nonempty should be inside of filter so it applies first, otherwise it is too slow.
    Your statement could look like this
    WITH MEMBER [Measures].[ParameterCaption] AS
    [Dim Date].[Date Key].CURRENTMEMBER.MEMBER_CAPTION
    MEMBER [Measures].[ParameterValue] AS
    [Dim Date].[Date Key].CURRENTMEMBER.UNIQUENAME
    MEMBER [Measures].[ParameterLevel] AS
    [Dim Date].[Date Key].CURRENTMEMBER.LEVEL.ORDINAL
    SELECT {[Measures].[ParameterCaption],
    [Measures].[ParameterValue], [Measures].[ParameterLevel]}
    ON COLUMNS
    , filter(
    nonempty([Dim Date].[Date Key].[Date Key],measures.measureName)
    ,measure.measurename >0
    ON ROWS
    FROM [Adventure Works cube]
    Jiri Neoral

  • Hard Time Getting JRE to work

    i dled j2re 1.4.2 and i install it and i dont know what to do next...i tried to do everything and cant get it to work....

    Got to give a lot more info than that. How are you trying to run it? I hope with an application.

  • I got an iTunes card and half the number is gone so I can't read it. Having a very hard time getting this fixed. Could someone please Email me on where n how I get this fixed. Thank you.

    Can someone please tell me how I can get find out the code on my iTunes card. Only half of the number is on my new card and I can't read it. Thank you.

    iTunes Store: Invalid, inactive, or illegible codes

  • Having difficult time getting subtotals to work

    Have a report where I am trying to get subtotals on group footer 1 which is by department.  Group footer 2 is by employee number.  I can get the totals to come out per employee, but I am now trying to get totals by employee  by department.  Example:
                                               deduction 1     deduction 2
    GF2       employee 1       $$$$$$                  $$$$$
    GF2       employee 2       $$$$$$                  $$$$$
    GF2       employee 3       $$$$$$                   $$$$$
      GF1      Dept Total         $$$$$$                   $$$$$
    Thanks

    Ah that helps.
    Modify the formula on the Details section to:
    whileprintingrecords;
    numbervar pen;
    numbervar gh1_sub;
    if {prhpost.postcode} = '001' then
        pen := pen + {prhpost.amount};
        gh1_sub := gh1_sub + pen;
        pen;
    Create a formula with this code and place it on the Group Footer 1 to display the total:
    whileprintingrecords;
    numbervar gh1_sub;
    Create a reset formula with this code and place this on the Group Header 1:
    whileprintingrecords;
    numbervar gh1_sub := 0;
    -Abhilash

  • HT1349 i cannot open anymore my iphone3gs. i just had it back to original setting because im having hard time sychronizing my phone to itunes. then i left my phone for about 5 hours then when i found it could not be activated, what am i gonna do with this

    i cannot open anymore my iphone3gs. just had it back to its original setting because in having hard time sychronizing this one.

    What specifically is the issue?

  • HT204406 I authorized a second computer on my iTunes account, and downloaded my library from the Cloud to my new computer. However, many songs only partially downloaded, and now I'm having a hard time getting rid of them to do full downloads.

    I authorized a second computer on my iTunes account and tried to get my first computer's library on my second computer via the Cloud. Many of the songs only partially downloaded, and I am having a hard time getting rid of the library with the partial downloads (so I can get full songs). I am considering nuking the current iTunes on the second computer and re-installing, giving myself a clean slate to work with. Is this the right way to go?

    How to use your iPod to move your music to a new computer

  • I was recently prompted to update iPhoto and make changes to the library.  I did it but it keeps hanging up in step 5 or 6 and won't complete the cycle.  I have used force quit, rebooted and started again several times.  How do i get this to work?

    I was recently prompted to update iPhoto and make changes to the library.  I did it but it keeps hanging up in step 5 or 6 and won't complete the cycle.  I have used force quit, rebooted and started again several times.  How do i get this to work?

    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    If that fails:
    Restore from your back up, repair the Library and try again.

  • TS2621 having a hard time getting my email account started. Keeps coming up with an error notice.

    Having a hard time getting my e-mail started on my iPhone 4. Trying to get connected to Verizon.

    Having a hard time getting my e-mail started on my iPhone 4. Trying to get connected to Verizon.

  • I have one key on my keyboard that I have to punch hard to get it to work. How do I fix this?

    I have one key on my keyboard that I have to punch hard to get it to work. How do I fix this?  Does a laptop have the same capability to pop off the keys and clean them like desktops do?

    Welcome to Apple Support Communities
    Connect the external drive and open a Finder window pressing the Finder icon in Dock. Then, drag the folder to Finder, so it will be copied to this external disk.
    If you can't copy this folder, probably you have to format the external disk or use an app that allows you to write in that external drive. Mac OS X can't write in NTFS external disks

  • Don't worry. We're working hard to get this fixed. Please try again later.

    Hi,
    I have SharePoint Online site.I set site collection  environment also but when i create User Group below  this issue has been occur
     Sorry, something went wrong "Don't worry. We're working hard to get this fixed. Please try again later."
    Please tell me how to fix this problem?
    thanks,
    Rajasekar

    Hi Raja,
    As the message described, it looks like the issue is trying to be fixed by product engineer.
    For solving this issue, you can post in our dedicated Office365 SharePoing Online forum from below link, there will be SharePoint Online backend engineer helping solve your SharePoint Online issue.
    http://community.office365.com/en-us/f/154/t/249148.aspx
    https://community.office365.com/en-us/f/154/t/255813.aspx
    Thanks
    Daniel Yang
    TechNet Community Support

  • I recently updraded the oporating system on my 4S phone and now I can't get my email.  I've rebooted several times to no avail. What should I do to get this thing working again?

    I recently upgraded my phone software to iOS 6 and now my email will not download.  I have tried to reboot the phone to no avail.  Anyone have any suggestions as to how I can get this phone working again?

    You can't merge the backups, you'll have to delete the backup of your old phone.  If it says it's currently in use when you try, that will normally clear up on its own but may take 3-5 days to do so.  Give it a few days and try deleting the old backup again.
    In the meantime, you can create a manual backup of your new phone on your computer by connecting it to your computer, opening iTunes, clicking on the name of your phone in iTuens, going to the Summary tab of your iTunes sync settings and clicking Back Up Now.  Also go to File>Devices>Transfer Purchases.  Then you'll be safe until you can start backup up to iCloud again.

  • ICal Server email invitations - how to test and get this feature working

    iCal Server email invitations - how to test and get this feature working
    Thanks Apple for introducing this nice little feature into iCal but then completely neglecting to write any sort of useful manual that can explain what to do when it doesn't work after you set it up for the first time.
    At long, long last we have finally got there after about 6 months of fiddling on and off, so I thought I had better post up the process since many have similar issues and it is hard to ascertain what is going on.
    Using an external email server was just a waste of time and it still wouldn't handle the replies properly even though it was supposed to handle '+addressing'. In the end I set up a special gmail account for the iCal server and finally got it working. I list here the process of configuring and testing the system to check that each little stage is working.
    Set up a Gmail account in Apple Mail to access and test in the usual way for any email account (e.g. [email protected].);
    Set the iCal server email to access the same email using the following settings:
    IMAP
    SMTP
    [email protected]
    smtp.gmail.com
    Port: 993 [x] Use SSL
    Port: 587 [x] Use SSL
    User & Pwd
    Login
    User & Pwd
    To test the settings:
    send out a test email from Apple Mail to a non-server email address that you can access to check it has been received;
    send out a test email from your non-server email account to [email protected] and check that it is received;
    this tells you that the GMail account is setup correctly and working
    Testing iCal:
    I noted that iCal was deleting any emails that arrive in the inBox in Apple Mail as soon as they arrived (this is to be expected);
    test that the invites are being sent from iCal by setting an event in iCal and inviting your non-server address (you may not see any sign of this in Apple Mail but you should catch it in the iCal server log and possibly in the Gmail sent mail box);
    check that the invite is received at your non-server account and Accept it in iCal on another machine - the reply is automatically sent back;
    the replies appear in Apple Mail but are quickly deleted by iCal. But their record for you to see is left in Gmail under 'All Mail';
    Accepted invites appear as a notification button on the top left hand bar on iCal where you click to acknowledge them and then the attendee is shown as a green circled tick instead of a grey circled ?.
    this shows that iCal invitations are working correctly. Whenever an event is updated, all invitees should be updated by email automatically.
    I hope this helps anyone - I could certainly have done with something similar when I started with looking at this.
    Anatole
    The Error and Access logfile in the Server app under iCal server are very useful in determining any errors. I got lots of imip errors when I didn't quite have the settings right. The port is critical and it won't tell you this is the problem if it fails.

    iCal Server email invitations - how to test and get this feature working
    Thanks Apple for introducing this nice little feature into iCal but then completely neglecting to write any sort of useful manual that can explain what to do when it doesn't work after you set it up for the first time.
    At long, long last we have finally got there after about 6 months of fiddling on and off, so I thought I had better post up the process since many have similar issues and it is hard to ascertain what is going on.
    Using an external email server was just a waste of time and it still wouldn't handle the replies properly even though it was supposed to handle '+addressing'. In the end I set up a special gmail account for the iCal server and finally got it working. I list here the process of configuring and testing the system to check that each little stage is working.
    Set up a Gmail account in Apple Mail to access and test in the usual way for any email account (e.g. [email protected].);
    Set the iCal server email to access the same email using the following settings:
    IMAP
    SMTP
    [email protected]
    smtp.gmail.com
    Port: 993 [x] Use SSL
    Port: 587 [x] Use SSL
    User & Pwd
    Login
    User & Pwd
    To test the settings:
    send out a test email from Apple Mail to a non-server email address that you can access to check it has been received;
    send out a test email from your non-server email account to [email protected] and check that it is received;
    this tells you that the GMail account is setup correctly and working
    Testing iCal:
    I noted that iCal was deleting any emails that arrive in the inBox in Apple Mail as soon as they arrived (this is to be expected);
    test that the invites are being sent from iCal by setting an event in iCal and inviting your non-server address (you may not see any sign of this in Apple Mail but you should catch it in the iCal server log and possibly in the Gmail sent mail box);
    check that the invite is received at your non-server account and Accept it in iCal on another machine - the reply is automatically sent back;
    the replies appear in Apple Mail but are quickly deleted by iCal. But their record for you to see is left in Gmail under 'All Mail';
    Accepted invites appear as a notification button on the top left hand bar on iCal where you click to acknowledge them and then the attendee is shown as a green circled tick instead of a grey circled ?.
    this shows that iCal invitations are working correctly. Whenever an event is updated, all invitees should be updated by email automatically.
    I hope this helps anyone - I could certainly have done with something similar when I started with looking at this.
    Anatole
    The Error and Access logfile in the Server app under iCal server are very useful in determining any errors. I got lots of imip errors when I didn't quite have the settings right. The port is critical and it won't tell you this is the problem if it fails.

  • A Playlist idiot. Why can't I get this to work?

    In iTunes I have music Playlists set to shuffle (blue double arrow button) and audio books Playlist set no shuffle. I have been unable to get my iPod to follow these settings. A suggested work around is to use the iPod Settings to set the shuffle function to "songs" when playing music and then switching to “off’ for audio books. There has to be a better way. How do I set the Playlists on my iPod to function the same as it does on iTunes?

    LeftyLucy,
    Using your process are you able to set your iPod to shuffle then listen to the audio book without it shuffling the chapters? I have tried your suggestion with the iPod setting set to shuffle and the chapters shuffled. This is the issue from my original post. I want to listen to music with the shuffle function and listen to audio books (no shuffle) without having to change the settings every time I switch.
    Keep in mind that is not a purchased audio nor a imported book.
    Using a tip from the following post:
    Tom Graves, "A Playlist idiot. Why can't I get this to work?" #11, 05:26pm Sep 28, 2005 CDT
    I have attempted to make the audio book file into an authenticate file but that did not help.

  • HT201322 Can't get this to work on iPad A1395 with iOS 6.1.2 - any suggestions?

    Can't get this to work on iPad A1395 with iOS 6.1.2 - any suggestions?

    If you mean hiding or unhiding apps, the article is incorrect since iOS 6 and the accompanying iTunes Store redesign were released. You can at this time only hide and unhide apps through iTunes on your computere.
    Regards.

Maybe you are looking for

  • Reverb Nation widget not working in Safari.

    Okay so ive created a HTML widget from Reverb Nation for a music player. Posted it to my GoDaddy website and it will not play. Ive tested this in Fire Fox and my iPhone and it works and plays.I go and test it on Safari and it will not play. Ive enabl

  • While using ibooks how to change page swipe from left to right vs top to bottom

    Somehow I changed a setting in my Ibooks to change page by scrolling from top to bottom of the screen. I want to have page turn by moving from left to right. I am using iPhone with operating 7. whatever is out at this day and time. Can anyone help? T

  • BitmapData.draw Security Sandbox and LocalTrusted not working?

    Hello there, wondering if anyone else is having the same problem -- I have a LocalTrusted security sandboxType -- and when i try to access a BitmapData.draw method on a progressive flv, i get the error message: SecurityError: Error #2135: Security sa

  • Printing RTF-Text using JTextPane

    G'day Does someone know how to print the drawed content of a JTextPane/JEditorPane? I derived a class from JTextPane and implemented Printable: public void print(Graphics g)   paintComponent(g); public void paintComponent(Graphics g)   super.paintCom

  • HT4759 Chrome scrolls too fast

    When I access iCloud Mail in Chrome the reading pane scrolls or bounces down faster than I can read it and it does not stop.  Is there a fix?