asked 335 views
3 votes
Java programming.

Create a class called FunFair that needs:

(The FunFair class has to be on an separate file

( 3 fields )
Name,string. The name of the fair, like Magic Kingdom, Animal Kingdom, Disney World, etc

Ownedbyint. The owner number is 1: city, 2: town 3= county 4= state 5= us 9= private

Haswater, Boolean, true if there is access to a pond, lake, etc. false if otherwise

(5methods only)

A constructor that accepts as arguments the values for the fields above in the order defined.

A copy constructor that makes a copy of the FunFair object

A set has water that accepts a FunFair object and returns a boolean if the two objects are equal. It returns true. If not then false. A to string method that returns a string that contains on separate lines (3 lines), the names and values for each field.

asked
User JR Tan
by
8.3k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

public class FunFair {

private String name;

private int ownedBy;

private boolean hasWater;

public FunFair(String name, int ownedBy, boolean hasWater) {

this.name = name;

this.ownedBy = ownedBy;

this.hasWater = hasWater;

}

public FunFair(FunFair fair) {

this.name = fair.name;

this.ownedBy = fair.ownedBy;

this.hasWater = fair.hasWater;

}

public boolean setHasWater(FunFair fair) {

return this.equals(fair);

}

public String toString() {

return "Name: " + name + "\\Owned by: " + ownedBy + "\\Has water: " + hasWater;

}

}

answered
User Claus Broch
by
8.2k points