Results 1 to 3 of 3
  1. #1
    dannyboi is offline Member
    Join Date
    Dec 2012
    Posts
    1
    Rep Power
    0

    Default help with this coding

    /*
    This class implements a vendor that sells one kind of items.
    A vendor carries out sales transactions.
    */

    public class Vendor
    {
    // Fields:
    private double Price = 0.0;
    private int stock = 0;
    private double initialMoney = 0.0;
    private double money = 0.0;
    private int qtySold = 0;


    // Constructor
    // Parameters:
    // int price of a single item in cents
    // int number of items to place in stock
    public Vendor(double p, int s)
    {
    Price = p;
    stock = s;
    }

    // Sets the quantity of items in stock.
    // Parameters:
    // int number of items to place in stock
    // Return:
    // None
    ... setStock ...
    {
    ...
    }

    // Returns the number of items currently in stock.
    // Parameters:
    // None
    // Return:
    // int number of items currently in stock
    ... getStock ...
    {
    ...
    }

    // Adds a specified amount (in cents) to the deposited amount.
    // Parameters:
    // int number of cents to add to the deposit
    // Return:
    // None
    ... addMoney ...
    {
    ...
    }

    // Returns the currently deposited amount (in cents).
    // Parameters:
    // None
    // Return:
    // int number of cents in the current deposit
    ... getDeposit ...
    {
    ...
    }

    // Implements a sale. If there are items in stock and
    // the deposited amount is greater than or equal to
    // the single item price, then adjusts the stock
    // and calculates and sets change and returns true;
    // otherwise refunds the whole deposit (moves it into change)
    // and returns false.
    // Parameters:
    // None
    // Return:
    // boolean successful sale (true) or failure (false)
    ... makeSale ...
    {
    ...
    }

    // Returns and zeroes out the amount of change (from the last
    // sale or refund).
    // Parameters:
    // None
    // Return:
    // int number of cents in the current change
    ... getChange ...
    {
    ...
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: help with this coding

    Go through the Forum Rules, especially the third paragraph; also go through Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming.

    Then edit your post accordingly. Note that to change the subject line, you will need to click "Go Advanced"

    Did you have a question?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: help with this coding

    I assume the "question" is "Please complete the methods for me". Not how it works.

Similar Threads

  1. Need Help Coding IO
    By loopsnhoops in forum New To Java
    Replies: 1
    Last Post: 05-18-2011, 04:44 PM
  2. Replies: 4
    Last Post: 10-25-2010, 04:49 PM
  3. Need help coding
    By ace_03 in forum New To Java
    Replies: 2
    Last Post: 11-25-2009, 06:16 PM
  4. Coding help
    By Java_Fanatic in forum New To Java
    Replies: 7
    Last Post: 10-15-2009, 05:37 AM
  5. Better coding
    By tomiu in forum New To Java
    Replies: 1
    Last Post: 04-09-2009, 08:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •