QuestionQuestion

Transcribed TextTranscribed Text

Question 1 Use object-oriented programming to write an application for a company that uses a subscription-based business model to loan out clothes such as office and party wear to female clients. A subscription costs $69 per 4 weeks. A client can make unlimited loan requests during her subscription, as long as she has no previous loan that has not been returned. There can be only one piece of clothes in each loan request. The chosen piece of clothes takes a day to be delivered. For example, if a piece of clothes is selected on Wednesday (say, 4th September 2019), then it will arrive at the address of the client the following day, that is, Thursday, 5th 2019 The subscription is automatically renewed. To cancel subscription, a client must o not have any loan that is unreturned, o pay up any outstanding balance, and o call to cancel before week 4 of each 4-week cycle. The UML diagram for the application is shown in Figure Q1. _clientId: int _name: str _address: str _balance: float __init__(self, clientId, name, address) clientId(self): int name(self):str address(self):str address(self, newValue) balance(self):float addPayment(self, amt):bool makePayment(self, amt): bool __str__(self):str _nextId = 1 _subscriptionRate = 69 _subscriptionId: int _startDate: datetime _client:Client _clothes:Clothes _deliveredDate datetime _returnedDate: datetime Subscription Client __init__(self, startDate, client) getSubscriptionRate(cls):int subscriptionId(self): int startDate(self):datetime client(self):Client clothes(self):Clothes clothes(self, newValue) returnedDate(self):datetime returnedDate(self, newValue) deliveredDate( self):datetime deliveredDate(self, newValue) returnClothes(self, returnDate):bool requestClothes(self, requestDate, clothes):bool __str__(self):str _clothesId: int _brand: str _size: int _price: float _onLoan: bool Clothes * 1 1 * * __init__(self, clothesId, brand, size, price) clothesId(self): int brand(self):str size(self):int price (se lf ):float onLoan(self):bool onLoan(self, newValue) __str__(self):str _clothes: [] _clients: {} _subscriptions: [] Company __init__(self) searchClient(self,clientId): Client searchClothes(self):Clothes searchSubscriptionByClientId(self, clientId):Subscription addClient(self,cientId, name. address):bool addSubscription(self, clientId, startDate):bool addClothes(self, clothe):bool cancelSubscription(self, clientId, cancelDate):bool returnClothes(self, clientId, returnDate) requestClothes(self, clientId, requestDate, clothes):bool clothesStr(self):str availableClothesStr(self) :str clientStr(self):str subscriptionSrr(self):str __str__(self):str Figure Q1 Write the following classes: (a) Client 􏰀 The object attributes are client id, name and address. The constructor has three parameters to initialise the three object attributes. There are accessor methods for all object attributes, and a mutator method for the address. 􏰀 A addPayment method has a parameter amount which is added to the client’s balance if the amount is positive, and the method returns True. Otherwise, the method returns False. 􏰀 A makePayment method that has a parameter amount which is subtracted from balance if the amount is positive, and the method returns True. Otherwise, the method returns False. Note that the balance may become negative, and it means that the client has paid in excess. 􏰀 A str method that returns the object attributes as a string in the format shown here: Test the class by creating the client in the example, and then invoke the methods you have written on the client object. (2 marks) (b) Clothes 􏰀 The object attributes are clothes id, brand, size, price and loan status. The loan status records True if the piece of clothes is currently loaned out, and False otherwise. The constructor has four parameters to initialise the first four attributes. Set loan status to False. There are accessor methods for each object attribute, and a mutator method for loan status. 􏰀 The str method returns all the values of the attributes as a string, with yes or no based on the loan status. Two examples are shown below: Test the class by creating the two Clothes objects in the example, and then invoke the methods you have written on the Clothes objects. (3 marks) (c) Subscription 􏰀 The object attributes are the subscription id, start date of subscription, client who made the subscription, the piece of clothes loaned under the subscription, if any, the date on which the piece of clothes is delivered to the client if there is a loan, and the date on which the piece of clothes is returned, if the loan has been returned. The constructor has two parameters to initialise the client and the start date of subscription. The subscription id is generated using a running number, implemented with a class attribute, _nextId. The subscription id of the first subscription is 1. The subscription id of the second subscription is 2, and so on. The piece of clothes, delivered date and return date are initialised to None. There are accessor methods for each object attribute, and mutator methods for the piece of clothes, delivery date and return date. 􏰀 Another class attribute records the subscription rate which is $69. A class method getSubscriptionRate returns the subscription rate. 􏰀 A returnClothes method has one parameter, return date, and method returns False if o there is no outstanding piece of clothes for the subscription or o the return date is before the date that the piece of clothes is delivered. Otherwise, the method handles the return of the piece of loaned clothes by setting the loan status of the piece of clothes to False, the object attribute (d) clothes to None, and updates the return date in the subscription. The method then returns True. 􏰀 A requestClothes method has two parameters, the request date and the piece of clothes. The method returns False if o a loan by the client has not been returned, or o the requested piece of clothes is currently already loaned out, or o the request date is before the start date of the subscription, or o the request date is before the returned date of the last loan. Otherwise, the method handles the request to loan a piece of clothes by setting the delivered date for the piece of clothes to be one day after the request date, the loan status of the requested piece of clothes to True, the object attribute clothes to the requested piece of clothes, and returns True. 􏰀 The str method returns the object attributes as a string. Three examples are shown below: Example 1: With no previous loan and no existing loan Example 2: With a previous piece of clothes that is loaned, returned and no existing loan Example 3: With a loan of a piece of clothes Test the class by creating the Subscription object in the example, and then invoke the methods you have written on the Subscription object. (10 marks) Company 􏰀 The object attributes are a collection of clothes (list), a collection of clients (dict) and a collection of subscriptions (list).The constructor initialises the three attributes as empty collections. 􏰀 There are three search methods, one for each of the object attributes. o A searchClient method returns a client in the collection that has the same client id as the parameter o A searchClothes method returns a piece of clothes in the collection that has the same clothes id as the parameter. o A searchSubscription method returns a subscription in the collection that is made by the client with the same client id as the parameter. Note that each client can make only one subscription. The method returns None if the search is unsuccessful. 􏰀 There are three add methods, one for each of the object attributes o An addClient method that creates and adds a client to the collection only if the collection does not contain a client with the same client id. o An addClothes method that adds a piece of clothes to the collection only if the collection does not contain a piece of clothes with the same clothes id. o The addSubscription method checks that the client making the subscription is an existing client, and that the client does not have a subscription yet. If so, the method creates a subscription and adds it to the collection only if the collection does not contain a subscription with the same subscription id. The subscription amount is added to the payment of the client making the subscription. o The method returns True if the add operation is successful, and False otherwise. 􏰀 A cancelSubscription method that has two parameters, a client id and the cancel date. The method returns False if o there is no client with the given client id or o if the client has an outstanding balance, or o the client does not have a subscription, or o the cancel date is earlier than the start date of the subscription o the cancel date is not before week 4 of the 4-week subscription cycle, Otherwise, the method removes the subscription and returns True. 􏰀 A returnClothes method that has two parameters, a client id and the return date. The method returns False if there is no client with the matching client id or if the client does not have a subscription. Otherwise, the method calls the returnClothes method on the subscription, and returns the result of the call. 􏰀 A requestClothes method that has three parameters, a client id, the request date and the requested piece of clothes. The method returns False if o the requested piece of clothes is already on loan or o there is no client with the matching client id or o the client does not have a subscription. Otherwise, the method calls the requestClothes method on the subscription, and returns the result of the call. 􏰀 There are four str methods for object attributes. o A clientStr method returns a string with each client detail on separate lines. o A clothesStr method returns a string with each clothes detail on separate lines. o A availableClothesStr method returns a string with each clothes detail on separate lines, for clothes currently not on loan. o A subscriptionStr method returns a string with each subscription detail on separate lines. 􏰀 The str method returns the object attributes as a string in the format shown below: Test the class by creating the Company object in the example, and then invoke the methods you have written on the Company object. For part (a), write your learning journey using the above guideline to document your learning experience. You are to copy and paste screenshots of your postings to the word document. Make sure your screenshots of your postings are readable. Copy also the links to each of your postings. In addition, write your answers to part (b) to the word document. You may supplement your answer with a class diagram, an example of which is shown in Figure Q1. Question 3 A delivery company provides both local and overseas deliveries which are either normal delivery or express delivery. Every sender must be registered. To have an item delivered, the sender calls up the company to request for the item to be picked up. The destinations of overseas deliveries are classified into 6 zones. Study the classes shown in Figure Q3 for the delivery application. Figure Q3a You are to write the following classes: (a) DeliveryException class, a subclass of Exception When the application encounters a business rule violation, an exception from this class is raised. (b) Sender class 􏰀 There are three object attributes: sender id, name and address. There are two class variables, o discount which currently is 0. Currently, there is no discount given to senders. o the maximum discount that any sender may have. Currently the value is 0.25 There is a constructor with three parameters to initialise the object attributes, and an accessor method for sender id. There are accessor and mutator method for only the class variable, discount. The mutator method for discount raises a DeliveryException when an attempt is made to set the discount to a negative value or to a value greater than the maximum discount that the delivery company is willing to give, with the message Discount given cannot be negative or Discount given cannot be greater than xx respectively, where xx is the maximum discount. 􏰀 A method __str__ returns a string representation of a sender. An example is shown here: (c) RetailSender class which is a subclass of Sender 􏰀 Beside the same object attributes as those in Sender, that is, sender Id, name and address, there is an additional object attribute, the business of the retailer. There are two class variables, o discount which currently is 0.15, as retailers currently get 15% off the delivery charges o the maximum discount that any retailer may get. Currently the value is 0.5 or 50%. There is a constructor with four parameters to initialise all four object attributes. 􏰀 A method __str__ returns a string representation of a retail sender. An example is shown here: (d) ItemDelivery class is abstract superclass 􏰀 There are seven object attributes: o the delivery id, o the sender requesting for the delivery, o the weight of the item, o the pickup date, o the destination, o whether the delivery is express (True) or normal(False), and o the delivered date. There is one class attribute in this class, _nextId which has the value 1. _nextId is used to auto generate running numbers for the delivery id. The delivery id for the first delivery is 1, the second is 2, and so on. There is a constructor with five parameters to initialise five object attributes excluding the delivery id and delivered date. The delivered date is set to None. It is set only when the item reaches its destination. The constructor raises a DeliveryException when an attempt is made to set the weight to a negative value or a value greater than the maximum weight allowed for a delivery, with the message Item weight xx cannot be negative or Item weight xxkg exceed maximum weight yykg respectively, where xx is weight of the item and yy is the maximum allowed weight. There are accessor method for all the object attributes, and a mutator method for delivered date. 􏰀 There are 4 abstract methods, of which one is an abstract class method. o getMaximumWeight returns the maximum weight allowed for an item that is to be delivered. This is an abstract class method that should be called by the constructor. o expectedDeliveredDate returns the expected date that the item will reach its destination. This is an abstract method. o nonExpressCharges returns the delivery charges for the item if delivered by normal delivery. This is an abstract method. o expressCharges returns the delivery charges for the item if delivered by express delivery. This is an abstract method. 􏰀 A charges method returns the charges for normal or express delivery if a discount does not apply, and it returns the discounted charges if a discount applies. 􏰀 A method __str__ returns a string representation of the delivery. Two examples are shown below, one showing an item has been delivered and the other showing that the item is still in transit. (e) LocalItemDelivery class is a subclass of ItemDelivery 􏰀 Besides having the same 7 object attributes as ItemDelivery, there is no additional object attribute for LocalItemDelivery. However, there are three class attributes. o express rate is 1.25, that is it costs 25% more to deliver in express mode. o the turnaround time is 1 day for normal delivery, o the base rate is $3 which must be added to the charges. 􏰀 The o getMaximumWeight returns 40. The weight limit is 40kg. o the expectedDeliveredDate for normal delivery is the pickup date added with the turnaround time. For expressed delivery, the turnaround time is halved. o nonExpressCharges returns the charges for an item with normal delivery, according to Table Q3a: Table Q3a o expressCharges is computed by multiplying the express rate and the charges for normal delivery. 􏰀 A method __str__ returns a string representation of a local delivery. Four examples are shown below: class implements each of the 4 abstract methods. Weight of item Charges < 3 kg $3 + base rate 3 to less than 5kg $7 + base rate 5kg to less 10kg $12 + base rate 10kg or more $30 + base rate (f) OverseasItemDelivery class is a subclass of ItemDelivery 􏰀 Besides the same 7 object attributes as ItemDelivery, there is one additional object attribute, zone. and two class attributes. o express rate is 1.4, that is it costs 40% more to deliver overseas in express mode. o the base rate is $10 The constructor raises a DeliveryException when an attempt is made to set the zone to a negative value or to a value greater than 6 with the message zone must be between 1 and 6. 􏰀 The class implements each of the 4 abstract methods. o getMaximumWeight returns 30. The weight limit is 30kg. o expectedDeliveredDate for normal delivery is the pickup date added with the turnaround time which is 3 times the zone of an overseas destination. For express delivery, the turnaround time is 2 times the zone of an overseas destination. For example, the delivery to zone 1 has a turnaround time of 3 days for normal delivery and 2 days for express delivery. o nonExpressCharges which returns charges for an item with normal delivery, according to Table Q3b: Table Q3b o expressCharges returns charges for the item with express delivery. expressCharges returns the value obtained by multiplying the sum of the express rate and zone/10, with the charges for normal delivery. 􏰀 A method __str__ returns a string representation of an overseas delivery. Four examples are shown below: Weight of item Charges < 3 kg $30 + base rate x zone/10 3 to less than 5kg $50 + base rate x zone/10 5kg to less 10kg $90 + base rate x zone/10 10kg or more $150 + base rate x zone/10 (g) DeliveryCompany class 􏰀 There are two object attributes: a collection of senders (dict) and a collection of item deliveries (list). There is a constructor with no parameter, and both object attributes are set to empty collections. 􏰀 A searchSender method returns a sender in the collection that has the same sender id as the parameter. The method returns None if the search is unsuccessful. 􏰀 There are two add methods, one for each of the object attributes o An addSender method that has one parameter, sender. It adds a sender to the collection only if the collection does not contain a sender with the same sender id. The method raises a DeliveryException with the message Sender xx is already recorded where xx is the sender id. o An addDeliveryItem method that adds a delivery to the collection 􏰀 A deliverItem method that has one parameter, a delivery id. The method raises a DeliveryException if the delivery id does not match any of the deliveries in the collection. The exception is raised with exception message Invalid delivery Id xx where xx is the delivery id. Otherwise, the method sets the delivered date of the located delivery to today’s date, and returns True. 􏰀 There are two str methods for object attributes. o A itemDeliveriesStr method returns a string with each item delivery detail on separate lines. o A sendersStr method returns a string with each sender detail on separate lines. 􏰀 The str method returns the object attributes as a string in the format shown here: Senders: Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Sender Id: S123 Name: Peter Tan Address: 12 Tampines Deliveries: Local Item Delivery Delivery Id: 1 Express: Yes weight: 4kg Charges: $12.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Collected: Thu, 05 Sep 2019 Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 2 Express: No weight: 4kg Charges: $10.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Collected: Not collected, in transit Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 5 Express: Yes weight: 4kg Charges: $10.62 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Sep 2019 Collected: Thu, 05 Sep 2019 Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Local Item Delivery Delivery Id: 6 Express: No weight: 4kg Charges: $8.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 3 Express: Yes weight: 4kg Charges: $76.50 Sep 2019 Sep 2019 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 4 Express: No weight: 4kg Charges: $51.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 7 Express: Yes weight: 4kg Charges: $65.02 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 8 Express: No weight: 4kg Charges: $43.35 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 10 Express: No weight: 4kg Charges: $44.20 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Wed, 11 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 9 Express: Yes weight: 4kg Charges: $70.72 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Mon, 09 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines (h) The application performs the following tasks: 􏰀 Create a DeliveryCompany object and populate it with the 2 senders, 4 local deliveries and 4 overseas deliveries. You may change the pickup dates to any date that helps demonstrate that your program is correct. 􏰀 The application must handle all exceptions including input error. Input error should be handled by allowing user to re-enter. Unless specified, simply handle DeliveryException raised by printing the error message. For example, Menu 1. List Senders 2. List Deliveries 3. Add Sender 4. Request Delivery Pickup 5. Deliver Item 0. Exit Enter option: a Please enter a whole number Menu 1. List Senders 2. List Deliveries 3. Add Sender 4. Request Delivery Pickup 5. Deliver Item 0. Exit Enter option: Please enter a whole number 􏰀 Provide a menu to allow a user to repeatedly select an option from the menu to perform an operation on the DeliveryCompany object. Menu 1. List Senders 2. List Deliveries 3. Add Sender 4. Request Delivery Pickup 5. Deliver Item 0. Exit 􏰀 Perform the following actions for each of the options: Option 1: Display the collection of senders Example: Enter option: 1 Sender List: Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Sender Id: S123 Name: Peter Tan Address: 12 Tampines Option 2: Display the collection of deliveries Example: Enter option: 2 Delivery List: Local Item Delivery Delivery Id: 1 Express: Yes weight: 4kg Charges: $12.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 2 Express: No weight: 4kg Charges: $10.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 5 Express: Yes weight: 4kg Charges: $10.62 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Local Item Delivery Delivery Id: 6 Express: No weight: 4kg Charges: $8.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 3 Express: Yes weight: 4kg Charges: $76.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 4 Express: No weight: 4kg Charges: $51.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 7 Express: Yes weight: 4kg Charges: $65.02 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 8 Express: No weight: 4kg Charges: $43.35 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 10 Express: No weight: 4kg Charges: $44.20 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Wed, 11 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 9 Express: Yes weight: 4kg Charges: $70.72 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Mon, 09 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Option 3: Prompt for the sender’s detail and the type of sender, and add the sender to the collection. Exception raised due to duplicate sender id should be handled by allowing the user 2 more attempts to re-enter the sender id or an empty string to abandon option 3. Example 1: Enter option: 3 Enter sender identification: s123 Enter sender name: test Enter address: 1 Road Enter type of sender - 1 for individual and 2 for retail: 1 Sender S123 is already recorded You have two attempts to correct sender identification Attempt 1 - Try another sender identification or <ENTER> to abandon: T111 Sender T111 is already recorded Attempt 2 - Try another sender identification or <ENTER> to abandon: S123 Sender S123 is already recorded Cannot add sender Example 2: Enter option: 3 Enter sender identification: T111 Enter sender name: Lee and Partner Enter address: 51 Clememti Road Enter type of sender - 1 for individual Enter type of goods being retailed: Toy Sender T111 is already recorded You have two attempts to correct sender Attempt 1 - Try another sender identification or <ENTER> to abandon: T222 Retail Business Toy Sender Id: T222 Name: Lee and Partner Address: 51 Clememti Road added! Example 3: Enter option: 3 Enter sender identification: S234 Enter sender name: John Enter address: 36 Joo Chiat Enter type of sender - 1 for individual and 2 for retail: 1 Sender Id: S234 Name: John Address: 36 Joo Chiat added Example 4: Enter option: 3 Enter sender identification: s123 Enter sender name: tom Enter address: 13 Haig Enter type of sender - Sender S123 is already You have two attempts to correct sender identification Attempt 1 - Try another sender identification or <ENTER> to abandon: Sender cannot added due to duplicate identification Option 4: Prompt for the sender id, and handle exception by allowing the user 3 attempts to enter the sender id that belongs to a registered sender. If a sender id is correct, prompt for item detail, and add a delivery to the collection. Example 1: and 2 for retail: 2 identification Road 1 for individual and 2 for retail: 1 recorded Enter option: 4 Please enter correct sender id within 1. Enter sender id <ENTER> to end: 1 Invalid sender Id 2. Enter sender id <ENTER> to end: 2 Invalid sender Id 3. Enter sender id <ENTER> to end: 3 Invalid sender Id Please register the sender first Example 2: Enter option: 4 Please enter correct sender id within 1. Enter sender id <ENTER> to end: a Invalid sender Id 3 attempts 3 attempts 2. Enter sender id <ENTER> to end: s123 Enter weight of item to deliver: 3 Enter pick up date in d/m/YYYY format: 5/9/2019 Enter destination address: somewhere By express? y for yes: y Enter type of delivery - 1 for Enter zone of destination: 3 Overseas Item Delivery Zone: 3 Express: Yes weight: 3.0kg Pick Up: Thu, 05 Sep 2019 Expected delivery date: Wed, 11 Sep 2019 Collected: Not collected, in transit Destination: somewhere Sender Id: S123 Name: Peter Tan Address: 12 Tampines added Example 3: Enter option: 4 Please enter correct sender id within 3 attempts 1. Enter sender id <ENTER> to end: s123 Enter weight of item to deliver: 0 Please enter a positive number for weight Enter weight of item to deliver: Please enter a number Enter weight of item to deliver: a Please enter a number Enter weight of item to deliver: 0.1 Enter pick up date in d/m/YYYY format: 1 Please enter pick up date in d/m/YYYY format Enter pick up date in d/m/YYYY format: 12 12 2019 Please enter pick up date in d/m/YYYY format Enter pick up date in d/m/YYYY format: 12/12/2019 Enter destination address: testing By express? y for yes: q Enter type of delivery - 1 for local and 2 for overseas: 0 Please enter either 1 for local or 2 for overseas Enter type of delivery - 1 for local and 2 for overseas: 3 Please enter either 1 for local or 2 for overseas Enter type of delivery - 1 for local and 2 for overseas: -1 Please enter either 1 for local or 2 for overseas Enter type of delivery - 1 for local and 2 for overseas: 1 Local Item Delivery Delivery Id: 11 Express: No weight: 0.1kg Charges: $6.00 Pick Up: Thu, 12 Dec 2019 Expected delivery date: Fri, 13 Dec 2019 Collected: Not collected, in transit Destination: testing Sender Id: S123 Name: Peter Tan Address: 12 Tampines added Option 5: Prompt for a delivery id, and update the delivered date to today’s date. List the delivery company object if the update is successful to demonstrate that your update is correctly performed. Example 1: Enter option: 5 Enter delivery id: 0 Invalid delivery Id 0 local and 2 for overseas: 2 Delivery Id: 11 Charges: $90.10 Example 2: Enter option: 5 Enter delivery id: 1 Senders: Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Sender Id: S123 Name: Peter Tan Address: 12 Tampines Deliveries: Local Item Delivery Delivery Id: 1 Express: Yes weight: 4kg Charges: $12.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Collected: Thu, 05 Sep 2019 Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 2 Express: No weight: 4kg Charges: $10.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Collected: Not collected, in transit Destination: 1 Delivery Road Sender Id: S123 Name: Peter Tan Address: 12 Tampines Local Item Delivery Delivery Id: 5 Express: Yes weight: 4kg Charges: $10.62 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Thu, 05 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Local Item Delivery Delivery Id: 6 Express: No weight: 4kg Charges: $8.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Fri, 06 Sep 2019 Collected: Not collected, in transit Destination: 1 Delivery Road Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 3 Express: Yes weight: 4kg Charges: $76.50 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 4 Express: No weight: 4kg Charges: $51.00 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Sender Id: S123 Name: Peter Tan Address: 12 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 7 Express: Yes weight: 4kg Charges: $65.02 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sat, 07 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 1 Delivery Id: 8 Express: No weight: 4kg Charges: $43.35 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Sun, 08 Sep 2019 Collected: Not collected, in transit Destination: 1 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 10 Express: No weight: 4kg Charges: $44.20 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Wed, 11 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 2 Delivery Id: 9 Express: Yes weight: 4kg Charges: $70.72 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Mon, 09 Sep 2019 Collected: Not collected, in transit Destination: 2 Some Land Retail Business Garment Sender Id: T111 Name: Tan and Family Address: 15 Tampines Overseas Item Delivery Zone: 3 Delivery Id: 11 Express: Yes weight: 3.0kg Charges: $90.10 Pick Up: Thu, 05 Sep 2019 Expected delivery date: Wed, 11 Sep 2019 Collected: Not collected, in transit Destination: somewhere Sender Id: S123 Name: Peter Tan Address: 12 Tampines Copy and paste the python code as a single program to the word document. Copy and paste ONE (1 screenshot - one screenshot showing the output from your program for options 1 to 5 for the various scenarios.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import datetime

class Client:
    def __init__(self, clientId, name, address):
       self._clientId = clientId
       self._name = name
       self._address = address
       self._balance = 0

    @property
    def clientId(self):
       return self._clientId

    @property
    def name(self):
       return self._name

    @property
    def address(self):
       return self._address

    @address.setter
    def address(self, newValue):
       self._address = newValue

    @property
    def balance(self):
       return self._balance

    def addPayment(self, amt):
       if amt >= 0:
            self._balance += amt
            return True
       else:
            return False...
$60.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Python Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats