Sale!

CSC 1302 Lab 10 Java Class Variables/Methods solved

Original price was: $35.00.Current price is: $30.00. $25.50

Category:

Description

5/5 - (13 votes)
Lab 10 Java Class Variables/Methods
Purpose:

Instance variables belong to the instance of a class, i.e., an object. Every object of that class has
its own copy of that instance variable. Changes made to a particular instance
variable donot reflect in other instances of that class.
Class variables are known as static variables. There is only one copy of that variable that is
shared with all instances of that class. If changes are made to that variable, all other instances
will see the change.

Instance methods belong to the object of the class, can only be called after an object of its
class is created. Static/class methods can be called without creating an object of class. They are
referenced by the class name itself or reference to the Object of that class.
In this assignment, we will practice how to use multiple classes and objects as well as class
variables/methods. Once a class is available, it’s like we have a new data type. Variables can be
defined with a type of this class and can refer to an object of this class. Methods can use this
class as parameter type or return type.

Task:
1. Write a Park class with the following class variables: 1) String ParkName; 2) int ParkID;
3) String ParkShape; and 4) double ParkLength. Please implement the following methods:
i) ParkNameGetter(): Return the name of the park.
ii) ParkIDGetter(): Return the ID of the park.
iii) ParkLengthGetter(): Return the length of the park.

Note that, 1) ParkLength is private while the other variables are public.
2) ParkShape only includes “Circle” and “Square”.
3) Parks may have the same name, but ParkID is unique.
4) Students should create the correct constructor.
2. Write a ParkClient class.

i) Create an array of Park:
– ParkArray has 5 elements;
– Set the first park in ParkArray with the following parameters: ParkName: CSC1302,
ParkID: Last 2 digits of PantherID, ParkShape: “Circle”, ParkLength: 5.
– Set the second park in ParkArray with the following parameters: ParkName: CSC1302,
ParkID: Last 2 digits of PantherID + 3, ParkShape: “Square”, ParkLength: 6.
– Randomly Set the other three parks in ParkArray.

ii) Print out the information of the Largest Park of all parks in the ParkArray.
Criteria:
1. Upload all of the .java and the .class files to the CSc1302 dropbox on http://
icollege.gsu.edu.
2. Your assignment will be graded based on the following criteria: (a) Are your programs
runnable without errors? (b) Do your programs complete the tasks with specified outputs?
(c) Do you follow the specified rules to define your methods and programs? (d) Do you
provide necessary comments include the programmer information, date, title of the
program and brief description of the program.

3. Please comment the important lines in the .java file as shown in the template. The
important lines including but not limited to i) variables, ii) for-loop, iii) while-loop, iv)
if-else statement, iv) methods. Please use your own words to describe what is your
purpose to write this line. A .java file without comment will be graded under a 40%
penalty.

4. Make sure that both the .java and .class files are named and uploaded to icollege
correctly. If any special package is used in the program, be sure to upload the package
too. Should you use any other subdirectory (whatsoever) your program would not be
graded, and you will receive a 0 (zero).

5. No copying allowed. If it is found that students copy from each other, all of these
programs will get 0.