Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- #include <ctime>
- #include<string>
- using namespace std;
- class Address {
- string city;
- string zipCode;
- string street;
- string number;
- public:
- Address(const string &city, const string &zipCode, const string &street, const string &number):
- city(city), zipCode(zipCode), street(street), number(number)
- {
- }
- void show() {
- cout << "City: " << city << endl
- << "Zip code: " << zipCode << endl
- << "Street: " << street << endl
- << "Number: " << number << endl;
- }
- };
- class Parcel {
- private:
- string _number;
- Address _deliveryAddress;
- public:
- Parcel(const string &number, const Address &deliveryAddress) :
- _number(number), _deliveryAddress(deliveryAddress) {
- }
- string getParcelId() {
- return _number;
- }
- void showDeliveryAddress() {
- _deliveryAddress.show();
- }
- };
- class Warehouse {
- Parcel **slots;
- int index = 0;
- public:
- Warehouse(int capacity) {
- slots = new Parcel*[capacity];
- }
- void addParcel(Parcel& parcel) {
- slots[index++] = &parcel;
- }
- void print() {
- for (int i = 0; i < index; ++i) {
- cout << slots[i]->getParcelId() << endl;
- slots[i]->showDeliveryAddress();
- }
- }
- };
- int main() {
- Address address = { "B-B", "43-300", "Willowa", "2" };
- Parcel p1("UID-1-1-220-2-2", address);
- Parcel p2("UID-2-5-117-1-4", address);
- Warehouse warehouse(10);
- warehouse.addParcel(p1);
- warehouse.addParcel(p2);
- warehouse.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement