JAVA
public String toString() {
return "Land Type: " + landType + "\n" +
"Address: " + address + "\n" +
"City: " + city + "\n" +
"State: " + state + "\n";
}
public boolean equals (Property obj) {
if (landType == obj.get_landType() && address == obj.address &&
city == obj.get_city() && state == obj.get_state())
return true;
else
return false;
}
public Property copy () {
Property copyOfObject = new Property(landType, address, city, state);
return (copyOfObject);
}
}
Examine the method equals.
a. What, if anything, does the method accept as input (parameter)?
b. What, if anything, does the method return?
c. How does the method determine if two objects are the same?
Examine the method copy.
a. What, if anything, does the method accept as input (parameter)?
b. What, if anything, does the method return?
c. How does the method determine if two objects are the same?
Examine the method toString.
a. What, if anything, does the method accept as input (parameter)?
b. What, if anything, does the method return?
c. How does the method determine if two objects are the same?
Answer:
equals() method:
a) equals method accept an object of class Property as input to match with the calling object.
b) It returns boolean value , either true or false , based on the matching of objects.
c) It matches all the variables of calling object to the variables of the passed object one by one.
copy() method:
a) It does not accept anything as input.
b) It returns another object which is a copy of calling object.
c) The method does not determine whether two objects are same, it just returns a new object which is the copy of calling object.
toString() method:
a) It does not accept anything as input.
b) It returns a string which prints variables one by one:
Land Type: landType Address: address City: city State: state
c) It does not determine whether two objects are same.
PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
JAVA public String toString() { return "Land Type: " + landType + "\n" + "Address: "...
Deliverable
A zipped NetBeans project with 2 classes
app
ZipCode
Address
Classes
Suggestion:
Use Netbeans to copy your last lab (Lab 03) to a new
project called Lab04.
Close Lab03.
Work on the new Lab04 project then.
The Address Class
Attributes
int number
String name
String type
ZipCode zip
String state
Constructors
one constructor with no input parameters
since it doesn't receive any input values, you need to use the
default values below:
number - 0
name - "N/A"
type...
Susceptible.java
interface Susceptible
{
public boolean infect(Disease disease);
public void forceInfection(Disease disease);
public Disease getCurrentDisease();
public void setImmune();
public boolean isImmune();
public Point getPosition();
}
Movable.java
interface Movable
{
public void move(int step);
}
public class Point {
private int xCoordinate;
private int yCoordinate;
/**
* Creates a point at the origin (0,0) and colour set to black
*/
public Point(){
xCoordinate = 0;
yCoordinate = 0;
}
/**
* Creates a new point at a given coordinate and colour...
In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...
java problem
here is the combination class
class Combination
{
int first,second,third, fourth;
public Combination(int first, int second, int
third,int fourth)
{
this.first=first;
this.second=second;
this.third=third;
this.fourth=fourth;
}
public boolean equals(Combination other)
{
if ((this.first==other.first)
&& (this.second==other.second) &&
(this.third==other.third) &&
(this.fourth==other.fourth))
return
true;
else
return
false;
}
public String toString()
{
...
In Java Programming Complete the Code that remains to be implemented follow the guide lines here and finish what code remains name of program class Student.java package course; public class Student { private String firstName; private String lastName; private Address homeAddress; private Address schoolAddress; private double[] testScores; // Four parameter constructor public Student(String firstName, String lastName, Address homeAddress, Address schoolAddress) { // Call the seven parameter constructor. Pass zeros for the three grades } // Five parameter constructor public Student(String...
2. Create ONE java file in Dr Java according the specifications below: A. Create a Country class a. Each Country object of the Country class should know (state) i. its name ii. its area (in square miles) iii. its population b. Each Country object should be able to (behavior) i. set initial population (setter) ii. get density (number of people per square mile) (getter) iii. adjust the set population by some amount (setter) iv. provide its name, area, and population...
public class CylindricalTank { private String idTag; // Unique String identifying the tank private double radius; // The non-negative radius of the base of the tank in meters private double height; // The non-negative height of the tank in meters private double liquidLevel; // The current height of the liquid in the tank in meters /** * CylindricalTank General Constructor */ public CylindricalTank(String tag, double...
Java Help 2. Task: Create a client for the Point class. Be very thorough with your testing (including invalid input) and have output similar to the sample output below: ---After declaration, constructors invoked--- Using toString(): First point is (0, 0) Second point is (7, 13) Third point is (7, 15) Second point (7, 13) lines up vertically with third point (7, 15) Second point (7, 13) doesn't line up horizontally with third point (7, 15) Enter the x-coordinate for first...
language is java
Restrictions: You are not allowed to use anything from the String, StringBuilder, or Wrapper classes. In general, you may not use anything from any other Java classes, unless otherwise specified. You are not allowed to use String literals in your code ("this is a string literal"). You are not allowed to use String objects in your code. The methods must be implemented by manipulating the data field array, The CSString Class: NOTE: Pay very careful attention to...
This is my code that i need to finish. In BoxRegion.java I have no idea how to create the constructor. I tried to use super(x,y) but It is hard to apply. And Also In BoxRegionHashTable, I don't know how to create displayAnnotation BoxRegion.java ------------------------------------------------ public final class BoxRegion { final Point2D p1; final Point2D p2; /** * Create a new 3D point with given x, y and z values * * @param x1, y1 are the x,y coordinates for point...