answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makvit [3.9K]
2 years ago
10

(Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and UPS®, offer a number of different shipping o

ptions, each with specific costs associated. Create an inheritance hierarchy to represent various types of packages. Use class Package as the base class of the hierarchy, then include classes Two Day Package and Over night Package that derive from Package. Base class Package should include data members representing the name, address, city, state and ZIP code for both the sender and the recipient of the package, in addition to data members that store the weight (in ounces) and cost per ounce to ship the package. Package’s constructor should initialize these data members. Ensure that the weight and cost per ounce contain positive values. Package should provide a public member function calculate Cost that returns a double indicating the cost associated with shipping the package. Package’s calculate Cost function should determine the cost by multiplying the weight by the cost per ounce. Derived class Two Day Package should inherit the functionality of base class Package, but also include a data member that represents a flat fee that the shipping company charges for two-day-delivery service. Two Day Package’s constructor should receive a value to initialize this data member. Two Day Package should redefine member function calculate Cost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculated by base class Package’s calculate Cost function. Class Over night Package should inherit directly from class Package and contain an additional data member representing an additional fee per ounce charged for overnight-delivery service. Over night Package should redefine member function calculate Cost so that it adds the additional fee per ounce to the standard cost per ounce before calculating the shipping cost. Write a test program that creates objects of each type of Package and tests member function calculate Cost.

Computers and Technology
1 answer:
lys-0071 [83]2 years ago
8 0

Answer:

Check the explanation

Explanation:

note: code is implemented as per the main method provided:

code:

using System;

public class Package

{

string senderName11;

string senderAddress1;

string senderCity1;

string senderState1;

string senderZip1;

string recipientName1;

string recipientAddress1;

string recipientCity1;

string recipientState1;

string recipientZip1;

decimal weight1;

decimal costPerOunce1;

public string SenderName11

{

get { return senderName11; }

set { senderName11 = value; }

}

public string SenderAddress1

{

get { return senderAddress1; }

set { senderAddress1 = value; }

}

public string SenderCity1

{

get { return senderCity1; }

set { senderCity1 = value; }

}

public string SenderState1

{

get { return senderState1; }

set { senderState1 = value; }

}

public string SenderZip1

{

get { return senderZip1;}

set { senderZip1 = value; }

}

public string RecipientName1

{

get { return recipientName1; }

set { recipientName1 = value; }

}

public string RecipientAddress1

{

get { return recipientAddress1; }

set { recipientAddress1 = value; }

}

public string RecipientCity1

{

get { return recipientCity1; }

set { recipientCity1 = value; }

}

public string RecipientState1

{

get { return recipientState1; }

set { recipientState1 = value; }

}

public string RecipientZip1

{

get { return recipientZip1; }

  set { recipientZip1 = value; }

}

public decimal Weight1

{

get { return weight1; }

set

{

if (value > 0)

weight1 = value;

else

Console.WriteLine("Weight1 can't be less tha zero");

}

}

public decimal CostPerOunce1

{

get { return costPerOunce1; }

set

{

if (value > 0)

costPerOunce1 = value;

else

Console.WriteLine("Cost per ounce can't be less than zero");

)

{

SenderName11 = senderName11;

SenderAddress1 = senderAddress1;

)

{

TwoDayDeliveryFee = twoDayDeliveryFee;

}

public override decimal CalculateCost()

{

return base.CalculateCost() + TwoDayDeliveryFee;

}

OvernightDeliveryFeePerOunce = overnightDeliveryFeePerOunce;

}

public override decimal CalculateCost()

{

return (CostPerOunce1 + OvernightDeliveryFeePerOunce) * Weight1;

}

}

class TestPackages

{

static void Main(string[] args)

{

Package regularPackage = new Package

(

"Peter Anderson",

"123 Main St, Ashville, NC 27111 ",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St Benson, NC 27222",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M

);

Console.WriteLine("\nRegular Package: ");

  Console.WriteLine(" Sender's Name: {0}",

      regularPackage.SenderName11);

  Console.WriteLine(" Sender's Address: {0}",

      regularPackage.SenderAddress1);

  Console.WriteLine(" Recipient's Name: {0}",

       regularPackage.RecipientName1);

  Console.WriteLine(" Recipient's Address: {0}",

       regularPackage.RecipientAddress1);

  Console.WriteLine(" Weight1: {0}"

, regularPackage.Weight1);

  Console.WriteLine(" Cost Per Ounce: {0:C}",

       regularPackage.CostPerOunce1);

  Console.WriteLine("Shipping Cost: {0:C}",

       regularPackage.CalculateCost());

Console.WriteLine(regularPackage.CalculateCost());

 

TwoDayPackage twoDayPackage = new TwoDayPackage

(

"Peter Anderson",

"123 Main St 123 Main St, Ashville, NC 27111",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M,

1.5M

);

  Console.WriteLine("\nTwo-Day Package: ");

  Console.WriteLine(" Sender's Name: {0}",

  twoDayPackage.SenderName11);

Console.WriteLine(" Sender's Address: {0}",

twoDayPackage.SenderAddress1);

  Console.WriteLine(" Recipient's Name: {0}",

   twoDayPackage.RecipientName1);

  Console.WriteLine(" Recipient's Address: {0}",

   twoDayPackage.RecipientAddress1);

  Console.WriteLine(" Weight1: {0}", twoDayPackage.Weight1);

  Console.WriteLine(" Cost Per Ounce: {0:C}",

   twoDayPackage.CostPerOunce1);

  Console.WriteLine(" Flat Fee: {0:C}",

   twoDayPackage.Weight1);

  Console.WriteLine(" Shipping Cost: {0:C}",

   twoDayPackage.CalculateCost());

OvernightPackage overnightPackage = new OvernightPackage

(

"Peter Anderson",

"123 Main St 123 Main St, Ashville, NC 27111",

"Ashville",

"NC 27111",

"MN 55416",

"Mary Brown",

"456 Broad St Benson, NC 27222",

"St. Petersburg",

"Benson",

"NC 27222",

160M,

0.1M,

1.5M

);

Console.WriteLine("\nOvernight Package: ");

  Console.WriteLine(" Sender's Name: {0}",

   overnightPackage.SenderName11);

  Console.WriteLine(" Sender's Address: {0}",

   overnightPackage.SenderAddress1);

  Console.WriteLine(" Recipient's Name: {0}",

   overnightPackage.RecipientName1);

  Console.WriteLine(" Recipient's Address: {0}",

   overnightPackage.RecipientAddress1);

  Console.WriteLine(" Weight1: {0}",

   overnightPackage.Weight1);

  Console.WriteLine(" Cost Per Ounce: {0:C}",

   overnightPackage.CostPerOunce1);

  Console.WriteLine(" Additional Cost Per Ounce: {0:C}",

   overnightPackage.OvernightDeliveryFeePerOunce);

  Console.WriteLine(" Shipping Cost: {0:C}",

   overnightPackage.CalculateCost());

Console.WriteLine(overnightPackage.CalculateCost()); Console.ReadKey();

}

}

The Result can be seen below:

You might be interested in
Imagine a business where there are no clear boundaries defined for data and systems ownership. As a security professional, descr
laiz [17]

Answer:

Loss of confidentiality, integrity and Availability

Explanation:

First I would start by explaining data ownership and system ownership

<u>Data ownership</u>:

Such an owner is responsible for safeguarding data, has all rights and complete control of the data. He or she can transfer data responsibility to someone else

<u>System ownership</u>:

The responsibility here is system maintenance, taking care of system functionalities, updating system and system software.

<u>Lack of data ownership</u>:

1. This affects privacy of data as there would be no one involved in the monitoring and taking care of the data. It would be at risk as sensitive information may get out and data may even be modified.

2. Lack of data ownership could bring about inconsistency in data

3. Lack of data ownership piles up risks to data which may cause great loss to data eventually.

<u>Lack of system ownership</u>:

1. There would be no one available to take care of issues that may come up with the system

2. If system gets to be outdated, it becomes open to malware and hackers

3. Work will be unable to be completed on the system.

<u>Loss of CIA triad</u>

CIA stands for confidentiality, Integrity and Availability

1. Without data ownership there would be access to data which is unauthorized. This brings about loss in confidentiality, and there could be issues with data availability

2. If system gets malware at the absence of system owner then there would be loss in confidentiality, integrity. Hackers would take control of the system and they would be able to use data.

3 0
2 years ago
n the video, McWhorter says that “textspeak” might be a good thing for young people’s brains. Why does he think this?
ANEK [815]

As you may know people learn in different ways. Some learn by audio, hands on, and simply just reading. When he says textspeak it more than likely means the text will be read to you in a way you would understand better.

3 0
2 years ago
Universal Containers recently rolled out a Lightning Knowledge implementation; however, users are finding unreliable and unrelat
blsea [12.9K]

Answer:

Option B and option C are the correct options.

Explanation:

When they have arisen an execution the following Knowledge related to the Lightning then, the users will find incredible and that Knowledge which is not related to the Articles for showing on the Salesforce Console's Knowledge One widget.

So, the following actions that are recommended to the consultant for checking the lack of quality are.

  • Firstly, they have to activate and customize wildcards to scan for objects.
  • Then, Establish an intuitive hierarchy for the Data Category.
7 0
2 years ago
When performing actions between your computer and one that is infected with a virus, which of the following offers NO risk of yo
DochEvi [55]
What are the options?
3 0
2 years ago
Read 2 more answers
Write a function named printtriangle that receives a parameter that holds a non-negative integer value and prints a triangle of
NemiM [27]
Static void PrintTriangle(int n){    for(;n>0;n--) {                Console.WriteLine(new String('*', n));    }}
5 0
2 years ago
Other questions:
  • The part of the computer that contains the brain, or central processing unit, is also known as the A.monitor B.modem C.keyboard
    10·1 answer
  • What tool extends the basic functionality provided in task manager with additional features and tools?
    8·1 answer
  • Grabar microphone audio icon_person click each item to hear a list of vocabulary words from the lesson. then, record yourself sa
    7·2 answers
  • The matrix theory is used in the ___ technique
    8·1 answer
  • Templates contain common layout and formatting that can save you time by not having to recreate documents from scratch. True or
    10·1 answer
  • A Class B network needs to be subnetted such that it supports 100 subnets and 100 hosts/ subnet. Which of the following answers
    8·1 answer
  • Given an alphabet, print all the alphabets up to and including the given alphabet.
    15·2 answers
  • Suppose that a class named ClassA contains a private nonstatic integer named b, a public nonstatic integer named c, and a public
    14·1 answer
  • Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
    10·1 answer
  • 4. Word Separator:Write a program that accepts as input a sentence in which all of thewords are run together but the first chara
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!