Question
Outline: In this project, you are expected to write a program that calculates and keeps the tirednessof a rectangular field as a 2D int array
Outline: In this project, you are expected to write a program that calculates and keeps the tirednessof 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. The program will read the name of the file as a stringwhich holds the planting input. The file will contain the following information: First the horizontal size of the rectangular field (sizeX) and the vertical size of the rectangular field (sizeY) will be given as intvalues. Then, a planting information will be given for each previous year as an information block. The information block will start with theyear information (currentYear) and how many plantings have been made during that year (plantingCount), both as intvalues. Next, plantingCount many planting information will be given as 4 inttuples: startXCoord, startYCoord, endXCoord, and endYCoordrepresenting this smaller rectangular area has been planted in this year.This currentYear plantingCount and that many plantingCount information blocks will keep continuing for each subsequent year until the currentYears value becomes 2017 which will be the last information block.Example inputfile:10 8201520 0 5 57082201610 0 5 52017 20 0 3 37 0 82Each information will be given IN A SINGLE LINEwithin the file as seen in the example above.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 1 every year the field has been planted.The tiredness of each part decreases by 1 every year the field has NOT been planted to a minimum of 0.Example output tiredness map for the inputgiven above:33331101103333110110333311011033331100001111110000111111000000000000000000000000
Input: The horizontal size of the fieldThe vertical size of the fieldYearly information block:oStarting with year information and number of plantings in that yearoThen the top left and bottom right coordinates of each planting in that yearOutput:The tiredness map of the whole field as a 2D int arrayNOTE: The coordinates of the top left corner part of the map is 0,0 and the maximum size of the field is 40, 40NOTE: No plantings given for the same year can overlap with one another.NOTE: You MUSTuse relativeaddress for the input file and put the file in the folder where your executable is.HINT: You should start with a 2D array where the value of EACHcell is 0.HINT: While calculating the map for the next year, using a temporary second 2D arrayis STRONGLY SUGGESTED(e.g., tirednessMap, newTirednessMap).
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started