Question: Here is the code for Pet class import java.io.PrintStream; import java.util.Scanner; public class Pet { //attributes private String name; private String species; private String gender;

 Here is the code for Pet class import java.io.PrintStream; import java.util.Scanner;

public class Pet { //attributes private String name; private String species; privateString gender; //default constructor public Pet() { this.name = ""; this.species =

Here is the code for Pet class

import java.io.PrintStream;

import java.util.Scanner;

public class Pet {

//attributes

private String name;

private String species;

private String gender;

//default constructor

public Pet() {

this.name = "";

this.species = "";

this.gender = "";

}

//parameterized constructor

public Pet(String name, String species, String gender) {

this.name = name;

this.species = species;

this.gender = gender;

}

//getters and setters

public String getName() {

return name;

}

public String getSpecies() {

return species;

}

public String getGender() {

return gender;

}

public void setName(String name) {

this.name = name;

}

public void setSpecies(String species) {

this.species = species;

}

public void setGender(String gender) {

this.gender = gender;

}

public void Read(Scanner scanner) {

name = scanner.nextLine();

species = scanner.nextLine();

gender = scanner.nextLine();

}

public void Write(PrintStream ps) {

ps.println(name);

ps.println(species);

ps.println(gender);

}

//returns pet details in JSON String format

public String GetJSON() {

String data = "{\"name\" : \"" + name + "\", \"species\" : \""

+ species + "\", \"gender\" : \"" + gender + "\"}";

return data;

}

@Override

public String toString() {

String data = "Name: " + name + " ";

data += "Species: " + species + " ";

data += "Gender: " + gender;

return data;

}

} // ends class pet

Thank you for the help!

In Java Write Appointment Class Class - Appointment Member Variables (all private) Data Typetion Variable Month Day Year Contains the month of the appointment. Contains the day of the appointment. Contains the year of the appointment Contains the pet being seen at the appointment. int Pet Pet Member Method Signatures and Descirptions (all public) Signature Description Default ConstructorDefault constructor. Sets the values of each member variable to default values Hint: Make sure that new is called for reference types Get/set methods for all member The get/set values for reference types should just get and variables set instance references. Write the contents of all member variables to the given instance of PrintStream. Assume the PrintStream is already open and ready to use. Data should be written on to separate lines. DO NOT ADD ANY DESCRIPTIVE TEXT IN THE OUTPUT. JUST PRINT THE VALUES IMPORTANT - Whatever data is written out should be readable by the Read method of this class. If descriptive text is added then Read will not work. oid Write(PrintStrean es) Read the contents of all member variables from the given instance of Scanner. Assume the following inside the method void Read(Scanner s) 1. Scanner is already open

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!