Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can someone please help me with this code and explain it to me? Description: In this, you are required to create class called Park. Park

Can someone please help me with this code and explain it to me?

Description:

In this, you are required to create class called "Park". Park has four fields: 1) StudentID (Integer), 2) length (Integer), 3) capacity (Integer), 4) shape (String).

Please fulfill the methods provided below while satisfying the requirements in red.

//First Name: jane

//Last Name: Jone

//Student ID: 001-23-4538

public class Park {

int StudentID;

String YourLastName;//make sure to use your last name as the variable name

private int length;

private int capacity;

private String shape;

//1. getLTD(): return the last two digits of the StudentID as an integer

public ____ getLTD(){}

//2. getLTC(): return the last two characters of the variable YourLastName as a String.

public ____ getLTC(){}

/*3. getShape(): return the shape of the park. We assume that each character is associated with a weight based on their position in the alphabet. The weight of 'a' is 1, the weight of 'b' is 2, the weight of 'c' is 3, so on and so force, the weight of 'y' is 25 and the weight of 'z' is 26. For example, if the result of getLTC() is "ab", then the weight of "ab" is 3. Based on the above information, if the weight of the getLTC() is less or equal to 26, the getShape() method will return "Circle"; otherwise, return "Square". */

Public ____ getShape(){ }

//Constructors

//4. Default constructor;

public ____ Park(){}

/*5. Constructor with an input of StudentID. This constructor initializes

assign StudentID

assign shape

assign length = getLTD()

Note that, the variable name of the input is YourFirstNameID such as Park (int nickID) if your firstname is "nick".

*/

public ____ Park(___ YourFirstNameID){}

//6. Constructor with an input of StudentID and capacity. This constructor initializes all fields. (similar to previous constructor)

Public ____ Park(___ YourFirstNameID, ___ capacity){}

//7. parkType(): return a String value based on the Capacity of the park. If the capacity is less than or equal to 30, return "Small"; if the capacity is larger than 30 but less than or equal to 60 return "Medium"; else return "Large".

Public ____ parkType(){}

//8. parkArea(): return the Area value (a double) based on the shape of the park. Assume that the length is the park radius if shape is circle, otherwise length is the side length if the shape is square.

public ____ parkArea(){}

/*9. crowdLevel(): the input of this method is an integer, while the output of this method is a String. We assume the input of this method is "x". Then, based on the equation ; if result is less than 1, return "NotCrowded"; if result is larger than 1 but less than 3, return "Crowded"; otherwise, return "VeryCrowded". Note that, if the input x is larger than the capacity, the method should return "Overload".

*/

public ______ crowdLevel(______){}

/*10. Write the method: printTriange ()

This method creates a triangle, the length and height are the number of letters in the instance variable of YourLastName. Students only need to print only one particular triangle, based on the following table and calculating the remainder as StudentID%6.

Remainder

Operation

0

Up Triangle + For-Loop

1

Up Triangle + While-Loop

2

Up Triangle + Do_While-Loop

3

Down Triangle + For-Loop

4

Down Triangle + While-Loop

5

Down Triangle + Do_While-Loop

For example, "Michael Jordan", with the length of last name as "Jordan" and with an odd ID of 7, will print out:

******

*****

****

***

**

*

For "Tom Brady" with an even ID of 5, the printout will be:

*

**

***

****

*****

*/

public _____ printTriangle (____ name){}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions