当前位置: 首页>>代码示例>>C++>>正文


C++ Road::asphalt方法代码示例

本文整理汇总了C++中Road::asphalt方法的典型用法代码示例。如果您正苦于以下问题:C++ Road::asphalt方法的具体用法?C++ Road::asphalt怎么用?C++ Road::asphalt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Road的用法示例。


在下文中一共展示了Road::asphalt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
  //print my name and this assignments title
  cout << "\n\nLab 1a,Road.h Road.cpp RoadDriver.cpp \n";
  cout << "Programmer: Aysin Oruz \n";
  cout << "Editor(s) used: JNotePad and Xcode \n";
  cout << "Compiler(s) used: Xcode and Terminal \n";
  cout << "Description: Road.cpp takes length, width of the road.";
  cout << " Then program calculates the values and returns thickness of the asphalt needed.\n\n";
  cout << "File: " <<  __FILE__ << endl;
  cout << "Compiled: " << __DATE__ << " at " << __TIME__ << endl;
  
  //create object
  Road road;
  
  //initlizating the objects
  road.setLength(15.50);  // set the length to a number in miles
  road.setWidth(20.25);  // set the width to a number in feet
  road.asphalt(10.75); //set the thickness of asphalt in inches
  
  //test setLenght function
  cout.setf(ios::fixed|ios::showpoint);
  cout << setprecision(2);
  cout << "\nTesting setLenght\n";
  cout << "Actual length: 15.50 miles \n";
  cout << "Expected length is " << road.getLength() << " miles"  << endl;
  assert ( road.getLength() > 15.4 && road.getLength() < 15.6);

  //test setWidth function
  cout << "\nTesting setWidth\n";
  cout << "Actual width: 20.25 feet \n";
  cout << "Expected width is " << road.getWidth() << " feet" << endl;
  assert ( road.getWidth() > 20.24 && road.getWidth() < 20.26);
  
  cout.setf(ios::fixed|ios::showpoint);
  cout << setprecision(2);
  cout << "\nTesting asphalt" << endl;
  cout << "Actual Volume is 1484628.750 cubic feet\n";
  cout << "Expected volume is " << road.asphalt(10.75) << " cubic feet\n";
  assert ( road.asphalt(10.75) > 1484628.749 && road.asphalt(10.75) < 1484628.751);

  
  // object copy testing, with assignment UPON declaration
  {
    //test setLenght function
    Road copy = road;
    cout.setf(ios::fixed|ios::showpoint);
    cout << setprecision(2);
    cout << "\nObject copy testing, with assignment UPON declaration" << endl;
    cout << "\nTesting setLenght\n";
    cout << "Actual length: 15.50 miles \n";
    cout << "Expected length is " << copy.getLength() << " miles"  << endl;
    assert ( copy.getLength() > 15.4 && copy.getLength() < 15.6);
    
    cout << "\nTesting setWidth\n";
    cout << "Actual width: 20.25 feet \n";
    cout << "Expected width is " << copy.getWidth() << " feet" << endl;
    assert ( copy.getWidth() > 20.24 && copy.getWidth() < 20.26);
  }
  
  // object copy testing, with assignment AFTER declaration
  {
    Road copy; copy = road;
    cout << "\nObject copy testing, with assignment AFTER declaration" << endl;
    cout << "\nTesting setLenght\n";
    cout << "Actual length: 15.50 miles \n";
    cout << "Expected length is " << copy.getLength() << " miles"  << endl;
    assert ( copy.getLength() > 15.4 && copy.getLength() < 15.6);
    
    cout << "\nTesting setWidth\n";
    cout << "Actual width: 20.25 feet \n";
    cout << "Expected width is " << copy.getWidth() << " feet" << endl;
    assert ( copy.getWidth() > 20.24 && copy.getWidth() < 20.26);
    
    
  }
}
开发者ID:aysin,项目名称:Comsci210,代码行数:77,代码来源:RoadDriver.cpp


注:本文中的Road::asphalt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。