Skip to content

Custom Exception for incrementSales() or incrementCosts() methods #1

@ichervachidze

Description

@ichervachidze

Both methods throw illegal argument exception. Create a custom exception for either (or both) method(s).

Where to find

Iteration 3, Inventory package, class Shop

incrementSales() method:

public void incrementSales(double increment) {
	if (increment < 0) throw new IllegalArgumentException();
	else this.sales += increment;
	}

incrementCosts() method:

//Increments costs by given amount
public void incrementCosts(double increment) {
	if (increment < 0) throw new IllegalArgumentException();
	else this.costs += increment;
       }

What to do

Create a custom exception with a descriptive name, such as NegativeSalesException/NegativeCostsException.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions