22 Ağustos 2019 Perşembe

COMP 101 – Art of Computing – Spring 2018


COMP 101 – Art of Computing – Spring 2018
Java Project (7.5% of total grade)
Field Tiredness Map (FTM) Project
Outline: In this project, you are expected to write a program that calculates and keeps the tiredness of a rectangular field as a 2D int array (tirednessMap) given the information about which parts of the field has been planted in the previous years.
First the horizontal size of the rectangular field (sizeX) and the vertical size of the rectangular field (sizeY) will be given as int values. Then, planting information will be given for each previous year as an information block. The information block will start with the year information (currentYear) , how many plantings have been made during that year (plantingCount) and plant_ids of plants that have been planted, respectively and all as int values.  Next, plantingCount many planting information will be given as 4 integer tuples: startXCoord, startYCoord, endXCoord, and endYCoord representing this smaller rectangular area has been planted in this year.
Define a Java class named “Plant” which holds the information of a plant. This class must have three fields:
·       plant_id(int)
·       plant_name (String)
·       tiredness_level (int)
and define one constructor that takes these 3 fields as parameters. Create the following 5 objects from this class and then add all of them to an array named “Plants” whose type is “Plant”.
Plant types and their information:
plant_id
plant_name
tiredness_level
1
artichoke
6
2
tomato
4
3
wheat
2
4
corn
3
5
potato
1

This currentYear – plantingCount and that many plantingCount information blocks will keep continuing for each subsequent year until the currentYear’s value becomes 2018 which will be the last information block.

Example input:
10 8
2016 2 1 5
0 0 5 5
7 0 8 2
2017 1 2
0 0 5 5
2018 2 4 3
0 0 3 3
7 0 8 2


Using this information, your program will calculate the tiredness of each part of the 2D rectangular field as follows:
·       Each cell in the 2D int array will represent the “tiredness of that part of the field.
·       The tiredness of each part starts at “0”.
·       The tiredness of each part increases by tiredness_level of each plant every year the field has been planted.
·       The tiredness of each part decreases by 3 every year the field has NOT been planted to a minimum of 0.



Example tiredness map for the input given above:
13
13
13
13
7
7
0
2
2
0
13
13
13
13
7
7
0
2
2
0
13
13
13
13
7
7
0
2
2
0
13
13
13
13
7
7
0
0
0
0
7
7
7
7
7
7
0
0
0
0
7
7
7
7
7
7
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0


Input:
·       The horizontal size of the field
·       The vertical size of the field
·       Yearly information block:
o   Starting with year information, number of plantings in that year and plant ids of plantings, respectively
o   Then the top left and bottom-right coordinates of each planting in that year.

Output:
·       The tiredness map of the whole field as a 2D int array
NOTE: The coordinates of the top left corner part of the map is 0,0 and the maximum size of the field is 40, 40
NOTE: No plantings given for the same year can overlap with one another.
HINT: You should start with a 2D array where the value of EACH cell is 0.
HINT: While calculating the map for the next year, using a temporary the second 2D array is STRONGLY SUGGESTED (e.g., tirednessMap, newTirednessMap).
HINT: You should obtain tiredness_level of plant, whose id is given as an input, from “Plants array”.





Sample Input/Outputs:
Input
Output
5 5
2017 2 4 1
0 0 2 2
1 3 4 4
2018 2 2 5
1 1 3 3
3 0 4 0
0 0 0 1 1
0 7 7 4 0
0 7 7 4 0
0 10 10 10 3
0 3 3 3 3
10 10
2015 3 1 4 3
2 2 2 7
5 4 8 7
8 1 9 3
2016 3 5 1 2
2 2 2 7
5 4 8 7
8 1 9 3
2017 4 2 3 1 5
0 0 2 2
3 8 6 9
5 4 8 5
8 1 9 3
2018 2 3 5
8 1 9 3
9 8 9 9
1 1 1 0 0 0 0 0 0 0
1 1 1 0 0 0 0 0 9 9
1 1 8 0 0 0 0 0 9 9
0 0 1 0 0 0 0 0 9 9
0 0 1 0 0 12 12 12 12 0
0 0 1 0 0 12 12 12 12 0
0 0 1 0 0 3 3 3 3 0
0 0 1 0 0 3 3 3 3 0
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1
5 5
2015 1 5
0 0 2 2
2016 1 3
0 0 2 2
2017 0
2018 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0


COMP 101 – Art of Computing – Spring 2018

COMP 101 – Art of Computing – Spring 2018 Java Project (7.5% of total grade) Field Tiredness Map (FTM) Project Outline : ...