vendredi 1 mars 2024

methode dispatch the package.

A package bulky if its volum (width x height x length) is >= 1000000 cm3 or when one of dimension >= 150 cm. 

A package heavy when its mass is greater than 20 kg. 

stacks: 

Standard (not bulky , not heavy). 

Special: that are heavy or bulky cant be hanled automatically. 

Rejected: package that are both heavy and bulky. 

Implementation public static string Solve(int width, int height, int length, int mass) return the name of the stack where the package should go


===============================

public static string Solve(int width, int height, int length, int mass)

    {

        int volume = width * height * length;

        bool isBulky = volume >= 1_000_000 || width >= 150 || height >= 150 || length >= 150;

        bool isHeavy = mass >= 20;


        if (isBulky && isHeavy)

            return "Rejected";

        if (isBulky || isHeavy)

            return "Special";

        return "Standard";

    }

Aucun commentaire:

Enregistrer un commentaire