⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 item.cpp

📁 BigC++的源码
💻 CPP
字号:
#include <iostream>

#include "item.h"

Item::Item(Product p, int q)
   : prod(p), quantity(q)
{  
}
   
Product Item::get_product() const
{
   return prod;
}

int Item::get_quantity() const
{
   return quantity;
}

double Item::get_total_price() const
{  
   return prod.get_price() * quantity;
}
   
void Item::print() const
{  
   const int COLUMN_WIDTH = 30;
   string description = prod.get_description();
           
   cout << description;

   // pad with spaces to fill column
      
   int pad = COLUMN_WIDTH - description.length();
   for (int i = 1; i <= pad; i++)
      cout << " ";
   
   cout << prod.get_price()
      << "   " << quantity 
      << "   " << get_total_price() << "\n";
}

⌨️ 快捷键说明

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