Problem Description
Hello! Please make sure to read all parts of this documentcarefully.
In this assignment, you will be applying your knowledge ofconstructor chaining, the this keyword, encapsulation,method overloading, visibility modifiers, the toString method, andsetters and getters. As we get further into the course, we arestarting to learn more elements of Object-Oriented Programming. Youwill createa Frog.java, Fly.java,and Pond.java file that will simulatehow they interact with each other in the real world.
Solution Description
Create files Fly.java, Frog.java,and Pond.java that will simulate how a pond ecosystemworks. You will be creating a number of fields and methods for eachfile. Based on the description given for each variable and method,you will have to decide whether or not the variables/method shouldbe static, and whether it should be private or public. To makethese decisions, you should carefully follow the guidelines onthese keywords as taught in lecture. In some cases, your programwill still function with an incorrect keyword.
Fly.java
This Java file defines fly objects that exists within thepond.
Variables
All variables must be not allowed to be directly modifiedoutside the class in which they are declared, unless otherwisestated in the description of thevariable. Hint: there is a specificvisibility modifier that can do this!
The Fly class must have these variables.
Constructors
You must use constructor chaining inat least two of your constructors. Duplicate code cannot exist inmultiple constructors.
Methods
Do not create any other methods than those specified. Any extramethods will result in point deductions. All methods must have theproper visibility to be used where it is specified they areused.
Frog.java
This Java file defines frog objects that exist within thepond.
Variables
All variables must be not allowed to be directly modifiedoutside the class in which they are declared, unless otherwisestated in the description of thevariable. Hint: there is a specificvisibility modifier that can do this!
The Frog class must have these variables:
Constructors
You must use constructor chaining inat least two of your constructors. Duplicate code cannot exist inmultiple constructors.
Methods
You must use method overloading atleast once. Do not create any other methods than those specified.Any extra methods will result in point deductions. All methods musthave the proper visibility to be used where it is specified theyare used.
Pond.java
This Java file is a driver, meaning it will contain andrun Frog and Fly objects and “drive” theirvalues according to a simulated set of actions. You can also use itto test your code. We require the following inyour Pond class:
Methods
Allowed Imports
To prevent trivialization of the assignment, you are not allowedto import any classes or packages.
Feature Restrictions
There are a few features and methods in Java that overlysimplify the concepts we are trying to teach or break our autograder. For that reason, do not use any of the following in yourfinal submission:
For Pond.java
public class Pond { public static void main(String[] args) {
}}
Problem Description Hello! Please make sure to read all parts of this document carefully. In this assignment, you will b
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am