本次Java代写要求体现面向对象编程的思想，在提供的Start Code基础上，不改变方法（Method/Function）名和返回类型（Return Type）的情况下完成经销商订单管理系统的编码程序并且使用JUnit进行单元测试。

# Reseller Order Management

A **reseller** gets orders from customers and supplies them with products taken from the stock; to refurnish the stock, the reseller sends orders to suppliers. Project classes are in the package **reseller**; the class **Reseller** is the facade. Package **example** contains the class **Example** and shows some examples of the methods that must be implemented. Look carefully at the example to understand the requirements.

A copy of the JDK documentation is available from the local server.

## R1: Stock Definition

The method *void* **setStock***(int initialLevel, String… productNames)* defines the name of the products that are considered and the number of available units in the beginning, that is the same for all units. In the following the term *product* is used to indicate both a product type and a stock element.

The method *Integer* **getStock***(String productName)* returns the number of available units for a specific product, or null if the type has not been defined.

## R2: Suppliers

The method *void* **addSupplier***(String supplierName, String… productNames)* introduces the name of a new supplier and the list of the supplied products.

The method *List<String>* **getProductsWithoutSuppliers***()* returns the list, sorted alphabetically, of the names of the products without suppliers; such a list is empty if all products have at least one supplier.

The method *List<String>* **getSupplierNames***(String productName)* returns the list, sorted alphabetically, of the names of the suppliers of the given product. Such a list is empty if the product has no suppliers.

## R3: Order Management

The reseller gets orders from customers through the method *void* **enterCOrder***(String customerName, String productName, int n)*. The parameters are the name of the client, the name of the product, and the number of requested units. The method generates a Customer Order (CO) associated to the type of product and to the customer.

The method may also generate a Supplier Order (SO) for a suitable supplier. A supplier order is associated to a supplier and to a product, and contains the number of requested units.

That is, two different lists are associated to each a type of product: a list of Customer Orders and a list of Supplier Orders. Each new order (either customer or supplier) is appended to the relevant list. The state of an order may be either pending (*p*) or fulfilled (*f*). Two important indicators may be extracted from the lists associated to a product: *customerNeeds*, the total number of units associated to pending customer orders; and *expectedSupplies*, the total number of units associated to pending supplier orders. The methods *int* **getCustomerNeeds***(String productName)* and *int* **getExpectedSupplies***(String productName)* returns these indicators.

The method *enterCOrder()* insert an order in the list of customer order, and sets it to the pending (*p*) state. Then:

- If
*expectedSupplies*is equal to zero:- If the available stock of the products is larger than the number of units requested in the order, the method sets the order to the fulfilled (
*f*) state, and removes from the stock the number of units. - If the available stock of the products is less than the number of units requested in the order, the method generates an order, asking for a number of units equal to the sum of the initial number of available units (
*initialLevel*) and the number of units requested by the order. The supplier is chosen among the ones associated with the given product, and is the first in alphabetic order among the ones with a minimum number of orders for the requested product. The order is then added to the supplier order list.

- If the available stock of the products is larger than the number of units requested in the order, the method sets the order to the fulfilled (
- If
*expectedSupplies*is larger than zero, then:- If the
*customerNeeds*is lower than the units available in the stock plus*expectedSupplies*, the method performs no action. - Otherwise (the
*customerNeeds*is greater than or equal to the units available in the stock plus*expectedSupplies*) the method generates a supplier order and behaves as in the previous case.

- If the

Please note that with these rules the units in the stock cannot be below zero.

The method *String* **getCOrders***(String productName)* returns a string containing information in the customer order list, while the method *String* **getSOrders***(String productName)* returns a string about the supplier order list.

A possible string is *“[c1,6,f;c2,10,p;c1,6,p]”*. The whole information is enclosed in square bracket, information about individual orders are separated by semicolons *“;”*. For each order there is the name of the customer (or supplier), the number of units, and the state (either *p* or *f*), all separated by commas.

The method *void* **delivery***(String supplierName, String productName)* set all pending orders for the given supplier and the given product to fulfilled (*f*), and add to the units in stock these number of units. Then, it tries to satisfy all customer orders, starting from the first in the queue.

- if the customer order may be fulfilled because the number of requested units is not larger than the number of available units in the stock, the units are removed from the stock and the order is set to fulfilled (
*f*) - if the customer order may not be fulfilled because the number of requested units is less than the number of available units in the stock, no action is performed.

## R4: Statistics

The method *SortedMap<String, Long>* **nOrdersPerCustomer***()* returns the number of orders issued by each customer, with the name of the customer sorted alphabetically.

The method *SortedMap<String, Integer>* **ratioSOrdersCOrdersPerProduct***()* returns, per each type of product associated with at least one customer order, the ratio between the number of supplier orders and the number of customer orders. Such a number is expressed in percentage as a number rounded to integer, for instance *32.3%* is *32*. The types of products are sorted alphabetically, for instance *{p1=50, p2=100}*.

**程序代写代做C/C++/JAVA/安卓/PYTHON/留学生/PHP/APP开发/MATLAB**

本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！

**E-mail:** [email protected] **微信:**dmxyzl003

如果您使用手机请先保存二维码，微信识别。如果用电脑，直接掏出手机果断扫描。