import random


class AbstractMelonOrder(object):
    """An abstract base class that other melon orders can inherit from."""

    def __init__(self, species, qty, order_type, tax):
        """Initialize melon order attributes for species, quanity, order type, tax, and shipped."""

        self.species = species
        self.qty = qty
        self.order_type = order_type
        self.tax = tax
        self.shipped = False

    def get_base_price(self):
        """Calculate base price (between 5-9) using splurge pricing."""

        base_price = random.randint(5, 9)

        return base_price

    def get_total(self):
        """Calculate total price of melon orders, including tax."""

        base_price = self.get_base_price()

        if self.species == "Christmas":
            base_price = base_price * 1.5

        total = (1 + self.tax) * self.qty * base_price

        if self.order_type == "international" and self.qty < 10:
            total += 3

        return total

    def mark_shipped(self):
        """Set shipped to true."""

        self.shipped = True


class DomesticMelonOrder(AbstractMelonOrder):
    """A domestic (in the US) melon order."""

    def __init__(self, species, qty):
        super(DomesticMelonOrder, self).__init__(species, qty, "domestic", 0.08)


class InternationalMelonOrder(AbstractMelonOrder):
    """An international (non-US) melon order."""

    def __init__(self, species, qty, country_code):
        super(InternationalMelonOrder, self).__init__(species, qty, "international", 0.17)

        self.country_code = country_code

    def get_country_code(self, country_code):
        """Return the country code."""

        return self.country_code


class GovernmentMelonOrder(AbstractMelonOrder):
    """A US Government melon order."""

    def __init__(self, species, qty):
        super(GovernmentMelonOrder, self).__init__(species, qty, "government", 0.0)

        self.passed_inspection = False

    def inspect_melons(self, passed):
        """Set value of passed_inspection."""

        self.passed_inspection = passed
