Advertisement
L3peha

Untitled

Feb 19th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. class ElasticMaterial :public Material
  2. {
  3. public:
  4. ElasticMaterial(float elasticModulus);
  5. float getStress(float strain);
  6. private:
  7. float elasticModulus;
  8. };
  9.  
  10. ElasticMaterial::ElasticMaterial(float elasticModulus)
  11. {
  12. this->elasticModulus = elasticModulus;
  13. }
  14.  
  15. float ElasticMaterial::getStress(float strain)
  16. {
  17. return strain * this->elasticModulus;
  18. }
  19.  
  20. class PlasticMaterial :public Material
  21. {
  22. public:
  23. PlasticMaterial(float elasticModulus, float strainLimit);
  24. float getStress(float strain);
  25. private:
  26. float elasticModulus;
  27. float strainLimit;
  28. };
  29.  
  30. PlasticMaterial::PlasticMaterial(float elasticModulus, float strainLimit)
  31. {
  32. this->elasticModulus = elasticModulus;
  33. this->strainLimit = strainLimit;
  34. }
  35.  
  36. float PlasticMaterial::getStress(float strain)
  37. {
  38. if (strain > this->strainLimit)
  39. {
  40. return this->strainLimit * this->elasticModulus;
  41. }
  42. return strain * this->elasticModulus;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement