Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <cmath>
  4. #include <ctime>
  5. #include<string>
  6.  
  7. using namespace std;
  8.  
  9. class Address {
  10. string city;
  11. string zipCode;
  12. string street;
  13. string number;
  14. public:
  15. Address(const string &city, const string &zipCode, const string &street, const string &number):
  16. city(city), zipCode(zipCode), street(street), number(number)
  17. {
  18.  
  19. }
  20.  
  21. void show() {
  22. cout << "City: " << city << endl
  23. << "Zip code: " << zipCode << endl
  24. << "Street: " << street << endl
  25. << "Number: " << number << endl;
  26. }
  27. };
  28.  
  29. class Parcel {
  30. private:
  31. string _number;
  32. Address _deliveryAddress;
  33. public:
  34. Parcel(const string &number, const Address &deliveryAddress) :
  35. _number(number), _deliveryAddress(deliveryAddress) {
  36. }
  37.  
  38. string getParcelId() {
  39. return _number;
  40. }
  41.  
  42. void showDeliveryAddress() {
  43. _deliveryAddress.show();
  44. }
  45. };
  46.  
  47. class Warehouse {
  48. Parcel **slots;
  49. int index = 0;
  50. public:
  51. Warehouse(int capacity) {
  52. slots = new Parcel*[capacity];
  53. }
  54.  
  55. void addParcel(Parcel& parcel) {
  56. slots[index++] = &parcel;
  57. }
  58.  
  59. void print() {
  60. for (int i = 0; i < index; ++i) {
  61. cout << slots[i]->getParcelId() << endl;
  62. slots[i]->showDeliveryAddress();
  63. }
  64. }
  65. };
  66.  
  67. int main() {
  68. Address address = { "B-B", "43-300", "Willowa", "2" };
  69.  
  70. Parcel p1("UID-1-1-220-2-2", address);
  71. Parcel p2("UID-2-5-117-1-4", address);
  72.  
  73. Warehouse warehouse(10);
  74. warehouse.addParcel(p1);
  75. warehouse.addParcel(p2);
  76. warehouse.print();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement