dispensertype.h

来自「C++编成数据结构与程序设计方法 D.S.Malk编著」· C头文件 代码 · 共 35 行

H
35
字号

//dispenserType Header File

class dispenserType
{
public:
    int getNoOfItems() const; 
      //Function to show the number of items in the machine.
      //Postcondition: The value of numberOfItems is returned.

    int getCost() const; 
      //Function to show the cost of the item.
      //Postcondition: The value of cost is returned.

    void makeSale();  
      //Function to reduce the number of items by 1.
      //Postcondition: numberOfItems--;

    dispenserType(int setNoOfItems = 50, int setCost = 50); 
      //Constructor 
      //Sets the cost and number of items in the dispenser
      //to the values specified by the user.
      //Postcondition: numberOfItems = setNoOfItems;
      //               cost = setCost;
      //               If no value is specified for a 
      //               parameter, then its default value is 
      //               assigned to the corresponding member 
      //               variable.

private:
    int numberOfItems;     //variable to store the number of 
                           //items in the dispenser
    int cost;  //variable to store the cost of an item
};

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?