ITI0011-2016:harjutus 20

Allikas: Kursused
Mine navigeerimisribale Mine otsikasti

Üldine

Kaitsmine: kuni 20. mai 2016
Kaust gitis: EX20

Mall

Muutke allolevat faili ja esitage see. <source lang="java"> import java.util.HashMap;

/**

* The farmer who does some hard work and earns money.
*/

public class Farmer {

   /**
    * Constructor.
    * @param name - farmer name
    * @param pastWeekSales - sales of the past week.
    *                      Key 1 indicates Monday, 7 indicates Sunday.
    */
   public Farmer(String name, HashMap<Integer, Integer> pastWeekSales) {
   }


   /**
    * Gets the name of the farmer.
    * @return the name.
    */
   public String getName() {
       return null;
   }
   /**
    * Get selling results for the last week.
    * @return HashMap, see constructor for description.
    */
   public HashMap<Integer, Integer> getSellingResults() {
       return null;
   }
   /**
    * Converts earned money HashMap to int array, which contains only amounts earned in the same order
    * as they were earned.
    * @param sellingResultsHashMap - earnings hashmap of the past week,
    *                              see constructor for description.
    * @return - array of ints of earned money (with length of 7) or null.
    */
   public int[] sortTheMess(HashMap<Integer, Integer> sellingResultsHashMap) {
       return null;
   }
   /**
    * Puts earned money amounts into order.
    * Notice, this is a static method which means
    * this is a general method, not connected to the farmer instance.
    * @param messyArray - unsorted array of ints
    * @return - sorted array of ints
    */
   public static int[] orderEarnings(int[] messyArray) {
       return null;
   }
   /**
    * Finds the max value from the earnings.
    * @param numArray - sorted or not sorted array of ints
    * @return - max earning during the past week.
    * 0 in the case max cannot be found.
    */
   public static int findTheMax(int[] numArray) {
       return 0;
   }
   /**
    * Finds average value from the earnings.
    * @param numArray - sorted or not sorted array of ints
    * @return - avg earning of the past week.
    * 0 in the case average cannot be found.
    */
   public static double findAvg(int[] numArray) {
       return 0;
   }
   /**
    * Puts final statistics into HashMap ("Avg":123.0, "Max":600.0).
    * @param avg - avg of earnings
    * @param max - max of earnings
    * @return - HashMap of final stats with keys "Avg" and "Max".
    */
   public static HashMap<String, Double> getFinalStats(double avg, int max) {
       return null;
   }
   /**
    * Compares sales of the farmer with another farmer's sales
    * on a specific day.
    * @param day - number of weekday
    * @param strangerSales - other farmer earnings
    * @return - true if calling farmer sales were bigger. false otherwise.
    */
   public boolean compareSales(int day, HashMap<Integer, Integer> strangerSales) {
       return false;
   }
   /**
    * Compares the first and the second half of the week based on the sells
    * if Sunday would be a free day
    * (compares mon, tue, wed sum to thu, fri, sat sum).
    * @param salesArr - sells array
    * @return - true if during the first half of the week earned
    * as much as on the second half
    */
   public boolean checkSalesIfSundayIsFree(int[] salesArr) {
       return false;
   }
   /**
    * Sums sales recursively.
    * No loops here!
    * @param salesArr - sales array of ints
    * @param length - length of array (the part to use).
    *               This can be smaller than salesArr.length
    * @return - sum of earnings
    */
   public int salesSum(int[] salesArr, int length) {
       return 1;
   }
   /**
    * To string method override.
    * @return preformatted string ("Farmer (farmeri nimi) teenis kokku (kokku teenitud summa) €")
    */
   @Override
   public String toString() {
       return null;
   }

}


</source>