fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Whiskey {
  6. private:
  7. string brand;
  8. string type;
  9. string distillery;
  10. string origin;
  11. double alcoholContent;
  12.  
  13. public:
  14. // Constructor
  15. Whiskey(string b, string t, string d, string o, double alc) {
  16. brand = b;
  17. type = t;
  18. distillery = d;
  19. origin = o;
  20. alcoholContent = alc;
  21. }
  22.  
  23. // Getter functions
  24. string getBrand() {
  25. return brand;
  26. }
  27.  
  28. string getType() {
  29. return type;
  30. }
  31.  
  32. string getDistillery() {
  33. return distillery;
  34. }
  35.  
  36. string getOrigin() {
  37. return origin;
  38. }
  39.  
  40. double getAlcoholContent() {
  41. return alcoholContent;
  42. }
  43. };
  44.  
  45. int main() {
  46. // Create a Jack Daniels Whiskey object
  47. Whiskey jd("Jack Daniel's", "Tennessee Whiskey", "Jack Daniel Distillery", "Lynchburg, Tennessee", 40.0);
  48.  
  49. // Display the details using getter functions
  50. cout << "Brand: " << jd.getBrand() << endl;
  51. cout << "Type: " << jd.getType() << endl;
  52. cout << "Distillery: " << jd.getDistillery() << endl;
  53. cout << "Origin: " << jd.getOrigin() << endl;
  54. cout << "Alcohol Content: " << jd.getAlcoholContent() << "%" << endl;
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
Brand: Jack Daniel's
Type: Tennessee Whiskey
Distillery: Jack Daniel Distillery
Origin: Lynchburg, Tennessee
Alcohol Content: 40%