The United Nations (UN) has set forth 17 goals for sustainable development. Goal 11 is designed to “Make cities inclusive, safe, resilient and sustainable.” Cities are often overpopulated, which puts strain on the resources and quality of life available in that location. Increased population leads to a need for more services (e.g. transportation, energy consumption) which can cause increased amounts of pollution and limitations on the available financial resources for many municipal projects.
In this project, we will consider one aspect of sustainable development: the creation of sustainable, public gardens and greenspace in urban areas. This will be the first in a set of two projects which revolve around this concept.
Sustainable Planting and Farming
Home gardens are experiencing a renaissance of sorts as people become aware of the benefits associated with local planting and farming. Planting trees, for example, helps to reduce air pollution and soil erosion, while growing food in a home garden limits exposure to pesticides and reduces the need for non-sustainable farming methods.
![]() |
![]() |
Urban areas have been promoting the idea of creating gardens and green space areas on tops of buildings, in parks, and in common areas as a way to promote better quality of life and to reduce stress among citizens. Consider the following video, which discusses a sustainable farming initiative in Washington, DC:
As an alternative situation, the following video describes the use of vacant/abandoned urban land in Detroit as sustainable farming area:
Sustainable urban farming requires knowledge of the growth patterns involved with specific plants, fruits, and vegetables. One problem that occurs when you decide to begin a garden is when and how often to plant. Suppose you wanted to plant a large garden, with many different vegetables and fruits. Often, multiple “plantings” of the same seeds occur to allow for a consistent schedule of available food. How would know how best to stagger your plantings? It turns out, it involves some simple math.
Where Can I Learn More?
Here are some links to additional information on this topic:
- Urban Gardening (Video), an extended case study video from GrowingAGreenerWorld.com
- Urban Gardening, an informational page from the National Garden Clubs
- Denver Urban Gardens, an example of large-scale urban gardening in Colorado
For this problem, you will begin the process of creating a planting schedule for an urban garden.
Java Project: Planting Schedules (Methods)
This project will provide you with an introduction to the fundamentals of user-defined methods in Java. In this project, you will…
- Develop code to read data from the standard input and produce data to the standard output.
- Write code that conforms to a programming style specified by the instructor.
- Select and implement the appropriate control structure(s) for this problem.
- Decompose the given problem into a sequence of single-purpose methods that are highly cohesive and loosely coupled.
As you write your code, be sure to properly document your code. Consult the Java Coding Guidelines document (provided by the instructor) for style expectations. Well-written code is easier to debug, easier to maintain over time, and easier to extend as new requirements arise.
Exercise #1: With this project, we will begin to create a simple program which will produce a planting schedule for a given plant, fruit, or vegetable. Create a class called Planting.java
in your Java development environment. Save your file.
Exercise #2: The planting schedule will wish to create will be based on the following user inputs:
- The name of the plant variety (a multi-word
String
object); - The start planting date (a
Calendar
object); - The number of days until maturity (an
int
> 0); - The number of days between plantings, i.e. the interval (an
int
> 0); - The fall frost date (a
Calendar
object).
Create six (6) static methods in your file besides main.
Five (5) of these methods will performs the necessary input operations (prompt, input, validate if requested) for the inputs above – one method per input. The sixth method will be used to echo-print the input values (nicely formatted) back to the user. Once the methods are created, test them out by adding code to your main
method to call these new methods.
Here are a few sample tests you can run to check if your program is working correctly; your prompts and error messages should appear exactly as shown here, and you can type in the listed input values when prompted. Make sure the format and text of your output matches the examples below:
Test Case #1
Please input the plant variety: Green Beans Please enter the start date as month day year: 05 1 2015 Please enter the number of days until maturity (an integer > 0): -1 *** ERROR! The input value must be an integer > 0. Please try again. Please enter the number of days until maturity (an integer > 0): 55 Please enter the number of days between plantings (an integer > 0): -1 *** ERROR! The input value must be an integer > 0. Please try again. Please enter the number of days between plantings (an integer > 0): 10 Please enter the fall frost date as month day year: 10 1 2015 You entered: Plant Variety? Green Beans Start Date? 05/01/2015 Days Until Maturity? 55 Days Between Plantings? 10 Fall Frost Date? 10/1/2015 |
Test Case #2
Please input the plant variety: Melons Please enter the start date as month day year: 05 1 2015 Please enter the number of days until maturity (an integer > 0): 70 Please enter the number of days between plantings (an integer > 0): 21 Please enter the fall frost date as month day year: 10 1 2015 You entered: Plant Variety? Melons Start Date? 05/01/2015 Days Until Maturity? 70 Days Between Plantings? 21 Fall Frost Date? 10/1/2015 |
Test Case #3
Please input the plant variety: Squash Please enter the start date as month day year: 05 1 2015 Please enter the number of days until maturity (an integer > 0): 48 Please enter the number of days between plantings (an integer > 0): 42 Please enter the fall frost date as month day year: 10 1 2015 You entered: Plant Variety? Squash Start Date? 05/01/2015 Days Until Maturity? 48 Days Between Plantings? 42 Fall Frost Date? 10/1/2015 |
Your program is now “complete”; we will extend this program in our next project. The next project will utilize Java arrays to produce a planting schedule, based on the input data provided by the user. Now that we have the input mechanism complete, our focus will turn to the computations necessary to transform the input data into meaningful information.
Deliverables
See the instructor for submission instructions and due date(s).