logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

Add the sample Plant class file provided on Moodle to the new project. Download and save the file, then right click on the saved file and select In IntelliJ, right click on the package (the default is “com.company”) and select paste.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Assignment Overview

A garden is defined here as consisting of plants. Using the provided class Plant, write an object-oriented Java program that keeps track of plants in such a garden.

  1. Add the sample Plant class file provided on Moodle to the new project. Download and save the file, then right click on the saved file and select In IntelliJ, right click on the package (the default is “com.company”) and select paste.

Tip: Make an object of class Plant and practice calling the constructors and methods in the class.

  1. In a new file located in the same package as the classes Main and Plant, create a “normal” public Java class to represent a garden. When the garden is first created there are no plants, but later it will have plants. The garden can hold at least 3 plants, and it has just been watered. To represent this information, the garden class must have
  • three private fields as data members:
  1. an array of Plant reference variables. The size of the array is set when the garden class object is created, but the array’s size must be at least 3 regardless of user
  2. the number of Plants currently in the garden, i. e. the number of plant objects currently being referenced by elements of the The number of plants referenced in the array always begins at zero.
  • the number of days since the garden was last watered. The garden is assumed to be watered when created, thus the number of days should begin at zero and never be set to a negative
  • a parameterized constructor that receives one parameter giving the maximum number of plants, i. giving the size of the array of Plant class type to be created. The Plant array reference variable is assigned to a new Plant array object of the size value received, but with at least 3 elements.
  • a default constructor that assumes the maximum number of plants to be 3 and otherwise acts just as the parameterized
  • a public “getter” (but no “setter”) method for the number of plants field. This returns the number of plants stored in the array, not the number of elements in the
  • a public “getter” and “setter” method for the number of days since watered
  • two public methods that each add one plant to the garden as long as there is room in the array of plants. Note that the number of plants field is the location of the next available element in the
  1. One add plant method receives one parameter, a Plant reference variable, and stores the reference in the first available position in the Plant The number of plants is increased upon successful planting.
  2. The other add plant method receives two parameters, the name of the plant and the height of the plant, creates a new Plant class object and stores the reference to the new object in the first available position in the Plant The number of plants is increased upon successful planting.
  • a public method that receives a plant number that is used as the index in the plant array and returns a String containing the name of the plant, the height of the plant, and whether the plant needs to be watered. If the plant number received is outside of the range of indexes or refers to an element in the array that does not reference a plant, the value null is

 

  • a public method to check if any of the Plant class objects needs to be watered by checking to see if the return value of each Plant object’s getNeedsWater method is true. If at least one Plant object needs to be watered, water the garden by calling the waterPlant method on each Plant object and set the garden’s number of days since watering field to
  1. In class Main, use the garden and Plant classes to create an application that allows the user to create then manage a virtual garden. Use user input to set the number of plants allowed in the garden object, then, in a loop, present a menu of options for the user to select. The loop should continue until the user elects to stop. The minimum options in the menu are
  • show the number of plants in the garden
  • add a plant to the garden by getting its name and height from the user
  • add a plant to the garden by giving a pre-defined object. You may use a call to one of the static

“factory” methods to create a plant object:

  • createFlower()
  • createShrub()
  • createTree()
  • increase the number of days since the garden has been watered by one

 

  • water the garden if at least one plant needs water
  • show the information about a specific plant in the garden
  • show the information about all plants in the garden
  • halt the application

Additional Requirements

  • The Plant class may not be changed in any way except for the package statement (if necessary).
  • There is no user I/O (input / output) in the garden class. All values given to the fields are either initial values or values passed to parametrized constructors or setter methods. Values of the fields are returned from the class via methods.
  • A reference variable and instance object of class util.Scanner must be used to read user input. (d)Identifiers must be descriptive, i. e. must self document.

(e)Indention of all code blocks (compound statements, anything in braces), including single statements following selection or while statements, is required.

Submitting

In IntelliJ, select File, Save All, then select File, Export to Zip File, navigate to a location you can find (but DO NOT put the zip inside the project folder), then click OK to save the Zip archive file. Finally, upload the zip archive file to Moodle.

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

843 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

573 Answers

Hire Me
expert
Husnain SaeedComputer science

718 Answers

Hire Me
expert
Atharva PatilComputer science

923 Answers

Hire Me
March
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30