C# 클래스 Supermarket.Inventory

파일 보기 프로젝트 열기: Clarksj4/Theme-Supermarket-Tycoon-World 1 사용 예제들

공개 메소드들

메소드 설명
Add ( Product product ) : void

Adds the given product to this inventory if it has a quantity greater than 0.

Contains ( string product ) : bool

Checks if this inventory contains a product by the given name.

Get ( string product, int quantity ) : Product

Gets the given product from this inventory. The amount returned is equal to the specified quantity or the amount stocked by this inventory; which ever is less. The inventory has an equal amount of product removed.

Inventory ( ) : System

A new, empty inventory.

Price ( string product ) : float

Checks the price per unit for a product by the given name. The Raises an exception if this inventory does not contain the given product.

Quantity ( string product ) : int

Checks the quantity of a product by the given name.

비공개 메소드들

메소드 설명
CalculateTotal ( ) : void

Calculates the total cost of all items in this inventory. TotalCost is equal to the sum of (quantity * price) for all products.

메소드 상세

Add() 공개 메소드

Adds the given product to this inventory if it has a quantity greater than 0.
public Add ( Product product ) : void
product Product The product to store in this inventory.
리턴 void

Contains() 공개 메소드

Checks if this inventory contains a product by the given name.
public Contains ( string product ) : bool
product string The name of the product to check for.
리턴 bool

Get() 공개 메소드

Gets the given product from this inventory. The amount returned is equal to the specified quantity or the amount stocked by this inventory; which ever is less. The inventory has an equal amount of product removed.
public Get ( string product, int quantity ) : Product
product string The name of the product to obtain
quantity int The desired amount of product
리턴 Product

Inventory() 공개 메소드

A new, empty inventory.
public Inventory ( ) : System
리턴 System

Price() 공개 메소드

Checks the price per unit for a product by the given name. The Raises an exception if this inventory does not contain the given product.
public Price ( string product ) : float
product string The name of the product to get a price per unit for
리턴 float

Quantity() 공개 메소드

Checks the quantity of a product by the given name.
public Quantity ( string product ) : int
product string The name of the product to check the quantity of.
리턴 int