Hi, i just need help for the understanding of the following question and no codes please.
I will be uploading my classes over here after i get the idea of what to do.
A package delivery system is needed for a courier service operating within Pakistan. Every package that needs to be delivered has the name, address and mobile number of the sender and receiver. The address consists of the street number (e.g. 312) suburb (e.g. abubakar block, garden town), city (e.g. Lahore) and province(e.g. Punjab). Every Package also has a weight (in kgs) and standard cost per kg to ship the package. The total cost of shipping a normal package is obtained by multiplying the standard cost with the weight.
There are two special kinds of packages. The overnight delivery package that has an additional cost per kg of delivering the package. The total cost of an overnight package is obtained by adding standard cost and additional cost and multiplying the result with weight of the package. The two-day delivery package has a flat fee that is charged in addition to the cost of the normal package to calculate the total cost.
i. Identify the classes needed to implement the above system and the relationship between those classes. Please give the interface (prototype) of the classes you have decided in this part.
Ii. Demonstrate Polymorphism: The cost of normal package, overnight delivery and two-day delivery packages are to be calculated differently.
• [Marks 20 ]Please implement the classes that you decided in part (i) and
• [Marks 20]Write a client program that should instantiate and loop through a dynamic array of packages demonstrating polymorphism. For every package it should print all the details of the sender and receiver in addition to the total delivery cost.
Identify the classes needed to implement the above system and the relationship between those classes. Please give the interface (prototype) of the classes you have decided in this part.
What should the following classes include?
Cause our instructor for programming is just obnoxious, she doesn't know how to teach and then if some goes against her teaching methods she deducts our marks.
And she hasn't explained classes to us properly.
Start with a class Adress->members: street number,suburb, city, province.
Next is a class Package->members: sender, receiver of type Address, weight and cost
From Package you inherit two classes: OvernightPackage and TwoDayPackage
the name, address and mobile number of the sender and receiver.
^^ little clues you start to pick up as you get a feel for design. You need 2 copies of identical type info. That begs wrapping it up into a class. (this was already said, but I wanted to show you HOW we made that decision to break this out into its own).
the polymorphism requirement, focus on setting up your design to ensure that you meet it. this requirement is 'extra' -- the problem as stated does not need the feature, but the professor wants it. So with a package class and a contactinfo class and polymorphism between them, the rest should be fairly simple -- package has a type (normal, 1day, 2day) that might be an enum... need a method to compute the costs... not too much more. Or you can do the different package types as said above, which is kind of excessive but it may be more intuitive for force fitting the polymorphism.
Following on what Jonnin and Learner2 said, write a draft of your class declarations. Don't worry about any syntax. Then re-read the assignment, word by word, and sentence by sentence. Do your classes have what's necessary to do the assignment? Modify them with whatever you've discovered is missing.
Then do it again. Re-read the assignment. Check every single sentence against your class declarations. Do you have what's needed?
Repeat until you're sure that you have what you need.
A wonderful trick to this is to turn the entire text of the assignment into comments in your source files. Move the comments to the parts of the code that implement them. Eventually, you should have moved all of the comments. Anything that's left hasn't been implemented.