I have done a decent amount of coding... but I need you to help me understand what I do not. Please, post comments so that I can learn from you.
Here are the instructions for this portion of the project:
Create the Monkey class, using the specification document as a guide. The Monkey class must do the following:
Here is the code I have:
import java.text.SimpleDateFormat;
public class Monkey extends RescueAnimal {
//constructor for input and calls super class
constructor
//assign Monkey class input and assign variables
public Monkey (String name, String type, String gender, int age,
float weight,
SimpleDateFormat aquisitionDate,
SimpleDateFormat statusDate, String acquisitionSource,
Boolean reserved, String
trainingLocation, SimpleDateFormat trainingStart,
SimpleDateFormat
trainingEnd, String trainingStatus,
String inServiceCountry, String inServiceCity, String
inServiceAgency, String
inServicePOC, String inServiceEmail, String inServicePhone,
String
inServicePostalAddress, int
tailLength, int height, int bodyLength, String species, int
measurementOfTorso, int
measurementOfSkull, int measurementOfNeck)
}
//calling super class constructor
super(name, type, gender, age, weight,
acquisitionDate, statusDate, acquisitionSource, reserved,
trainingLocation, trainingStart, trainingEnd, trainingStatus,
inServiceCountry, inServiceCity,
inServiceAgency,
inServicePOC, inServiceEmail, inServicePhone,
inServicePostalAddress);
//assign variables of Monkey class
this.tailLength = tailLength;
this.height = height;
this.bodyLength = bodyLength;
this.species = species;
this.measurementOfTorso = measurementOfTorso;
this.measurementOfSkull = measurementOfSkull;
this.measurementOfNeck = measurementOfNeck;
}
//define variables for Monkey class
private int tailLength;
private int height;
private int bodyLength;
private String species;
private int measurementOfTorso;
private int measurementOfSkull;
private int measurementOfNeck;
//define accessor functions
public int getTailLength() {
return getTailLength;
}
public int getHeight() {
return height;
}
public int getBodyLength() {
return bodyLength;
}
public String getSpecies() {
return species;
}
public int getMeasurementOfTorso() {
return measurementOfTorso;
}
public int getMeasurementOfSkull() {
return measurementOfSkull;
}
public int getMeasurementOfNeck() {
return measurementOfNeck;
}
//define mutator functions
public void setTailLength(int tailLength) {
this.tailLength = tailLength;
}
public void setHeight(int height) {
this.height = height;
}
public void setBodyLength(int bodyLength) {
this.bodyLength = bodyLength;
}
public void setSpecies(String species) {
this.species = species;
}
public void setMeasurementOfTorso(int
measurementOfTorso) {
this.measurementOfTorso =
measurementOfTorso;
}
public void setMeasurementOfSkull(int
measurementOfSkull) {
this.measurementOfSkull =
measurementOfSkull;
}
public void setMeasurementOfNeck(int
measurementOfNeck) {
this.measurementOfNeck =
measurementOfNeck;
}
}
IT ONLY GIVES ME SO MUCH ROOM TO POST: HERE IS THE ABSTRACT CLASS... I ALSO HAVE DOG CLASS AND AM WORKING ON A DRIVER CLASS NOW:
import java.text.SimpleDateFormat;
public class RescueAnimal {
// Instance variables
private String name;
private String type;
private String gender;
private int age;
private float weight;
private SimpleDateFormat acquisitionDate;
private SimpleDateFormat statusDate;
private String acquisitionSource;
private Boolean reserved;
private String trainingLocation;
private SimpleDateFormat trainingStart;
private SimpleDateFormat trainingEnd;
private String trainingStatus;
private String inServiceCountry;
private String inServiceCity;
private String inServiceAgency;
private String inServicePOC;
private String inServiceEmail;
private String inServicePhone;
private String inServicePostalAddress;
// Constructor: initialize objects
public RescueAnimal() {
}
// Add Accessor Methods here: aka "getters"
public String getName() {
return name;
}
public String getType() {
return type;
}
public String getGender() {
return gender;
}
public int getAge() {
return age;
}
public float getWeight() {
return weight;
}
public SimpleDateFormat getAcquisitionDate() {
return acquisitionDate;
}
public SimpleDateFormat getStatusDate() {
return statusDate;
}
public String getAcquisitionSource() {
return acquisitionSource;
}
public Boolean getReserved() {
return reserved;
}
public String getTrainingLocation() {
return trainingLocation;
}
public SimpleDateFormat getTrainingStart() {
return trainingStart;
}
public SimpleDateFormat getTrainingEnd() {
return trainingEnd;
}
public String getTrainingStatus() {
return trainingStatus;
}
public String getInServiceCountry() {
return inServiceCountry;
}
public String getInServiceCity() {
return inServiceCity;
}
public String getInServiceAgency() {
return inServiceAgency;
}
public String getInServicPOC() {
return inServicPOC;
}
public String getInServiceEmail() {
return inServiceEmail;
}
public String getInServicePhone() {
return inServicePhone;
}
public String getInServicePostalAddress() {
return
inServicePostalAddress;
}
// Add Mutator Methods here: aka "modifiers"
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setAge(int age) {
this.age = age;
}
public void setWeight(float weight) {
this.weight = weight;
}
public void setAcquisitionDate(SimpleDateFormat
acquisitionDate) {
this.acquisitionDate =
acquisitionDate;
}
public void setStatusDate(SimpleDateFormat statusDate)
{
this.statusDate = statusDate;
}
public void setAcquisitionSource(String
acquisitionSource) {
this.acquisitionSource =
acquisitionSource;
}
public void setReserved(Boolean reserved) {
this.reserved = reserved;
}
public void setTrainingLocation(String
trainingLocation) {
this.trainingLocation =
trainingLocation;
}
public void setTrainingStart(SimpleDataFormat
trainingStart) {
this.trainingStart =
trainingStart;
}
public void setTrainingEnd(SimpleDateFormat
trainingEnd) {
this.trainingEnd =
trainingEnd;
}
public void setTrainingStatus(String trainingStatus)
{
this.trainingStatus =
trainingStatus;
}
public void setInServiceCountry(String
inServiceCountry) {
this.inServiceCountry =
inServiceCountry;
}
public void setInServiceCity(String inServiceCity)
{
this.inServiceCity =
inServiceCity;
}
public void setInServiceAgency(String inServiceAgency)
{
this.inServiceAgency =
inServiceAgency;
}
public void setInServicePOC(String nServicePOC)
{
this.inServicePOC =
inServicePOC;
}
public void setInServiceEmail(String inServiceEmail)
{
this.inServiceEmail =
inServiceEmail;
}
public void setInServicePhone(String inServicePhone)
{
this.inServicePhone =
inServicePhone;
}
public void setInServicePostalAddress(String
inServicePostalAddress) {
this.inServicePostalAddress =
inServicePostalAddress;
}
}
Working code implemented in Java and appropriate comments provided for better understanding:
Here I am attaching code for these files:
Source code for Dog.java:
public class Dog extends RescueAnimal {
// Instance variable
public String breed;
// Constructor
public Dog() {
}
// Accessor Method
public String getBreed() {
return breed;
}
// Mutator Method
public void setBreed(String dogBreed) {
breed = dogBreed;
}
}
Source code for Monkey.java:
//Inherit from the RescueAnimal class using extends
public class Monkey extends RescueAnimal {
public enum Species{Capuchin, Guenon, Macaque,
Marmoset, Squirrel, Tamarin}
//Variables are public and shared with other
class
public float tailLength;
public float height;
public float bodyLength;
public String species;
public float measurementOfTorso;
public float measurementOfSkull;
public float measurementOfNeck;
//Constructor
public Monkey() {
}
//Accessor methods are used to get the values for all
implemented attributes
public float getTailLength() {
return tailLength;
}
public float getHeight() {
return height;
}
public float getBodyLength() {
return bodyLength;
}
public String getSpecies() {
return species;
}
public float getMeasurementOfTorso() {
return measurementOfTorso;
}
public float getMeasurementOfSkull() {
return measurementOfSkull;
}
public float getMeasurementOfNeck() {
return measurementOfNeck;
}
//Mutator methods are used for all implemented
attributes
public void setTailLength(float tailLength) {
this.tailLength = tailLength;
}
public void setHeight(float height) {
this.height = height;
}
public void setBodyLength(float bodyLength) {
this.bodyLength = bodyLength;
}
public void setMeasurementOfTorso(float
measurementOfTorso) {
this.measurementOfTorso =
measurementOfTorso;
}
public void setMeasurementOfSkull(float
measurementOfSkull) {
this.measurementOfSkull =
measurementOfSkull;
}
public void setMeasurementOfNeck(float
measurementOfNeck) {
this.measurementOfNeck =
measurementOfNeck;
}
}
Source code for RescueAnimal.java:
import java.text.SimpleDateFormat;
public class RescueAnimal {
// Instance variables
private String name;
private String type;
private String gender;
private int age;
private float weight;
private SimpleDateFormat acquisitionDate;
private SimpleDateFormat statusDate;
private String acquisitionSource;
private Boolean reserved;
private String trainingLocation;
private SimpleDateFormat trainingStart;
private SimpleDateFormat trainingEnd;
private String trainingStatus;
private String inServiceCountry;
private String inServiceCity;
private String inServiceAgency;
private String inServicePOC;
private String inServiceEmail;
private String inServicePhone;
private String inServicePostalAddress;
// Constructor
public RescueAnimal() {
}
public RescueAnimal(String name, String type, String
gender, int age, float weight) {
this.name = name;
this.type = type;
this.gender = gender;
this.age = age;
this.weight = weight;
}
// Accessor methods for all attributes
public String getName() {
return name;
}
public String getType() {
return type;
}
public String getGender() {
return gender;
}
public int getAge() {
return age;
}
public float getWeight() {
return weight;
}
public SimpleDateFormat getAcquisitionDate() {
return acquisitionDate;
}
public SimpleDateFormat getStatusDate() {
return statusDate;
}
public String getAcquisitionSource() {
return acquisitionSource;
}
public Boolean getReserved() {
return reserved;
}
public String getTrainingLocation() {
return trainingLocation;
}
public SimpleDateFormat getTrainingStart() {
return trainingStart;
}
public SimpleDateFormat getTrainingEnd() {
return trainingEnd;
}
public String getTrainingStatus() {
return trainingStatus;
}
public String getInServiceCountry() {
return inServiceCountry;
}
public String getInServiceCity() {
return inServiceCity;
}
public String getInServiceAgency() {
return inServiceAgency;
}
public String getInServicePOC() {
return inServicePOC;
}
public String getInServiceEmail() {
return inServiceEmail;
}
public String getInServicePhone() {
return inServicePhone;
}
public String getInServicePostalAddress() {
return
inServicePostalAddress;
}
//Mutator methods for all implemented attributes
public void setGender(String gender) {
this.gender = gender;
}
public void setName(String name) {
this.name = name;
}
public void setType(String type) {
this.type = type;
}
public void setAge(int age) {
this.age = age;
}
public void setWeight(float weight) {
this.weight = weight;
}
public void setAcquisitionDate(SimpleDateFormat
acquisitionDate) {
this.acquisitionDate =
acquisitionDate;
}
public void setStatusDate(SimpleDateFormat statusDate)
{
this.statusDate = statusDate;
}
public void setReserved(Boolean reserved) {
this.reserved = reserved;
}
public void setTrainingLocation(String
trainingLocation) {
this.trainingLocation =
trainingLocation;
}
public void setTrainingStart(SimpleDateFormat
trainingStart) {
this.trainingStart =
trainingStart;
}
public void setTrainingEnd(SimpleDateFormat
trainingEnd) {
this.trainingEnd =
trainingEnd;
}
public void setTrainingStatus(String trainingStatus)
{
this.trainingStatus =
trainingStatus;
}
public void setInServiceCountry(String
inServiceCountry) {
this.inServiceCountry =
inServiceCountry;
}
public void setInServiceCity(String inServiceCity)
{
this.inServiceCity =
inServiceCity;
}
public void setInServiceAgency(String inServiceAgency)
{
this.inServiceAgency =
inServiceAgency;
}
public void setInServicePOC(String inServicePOC )
{
this.inServicePOC =
inServicePOC;
}
public void setInServiceEmail(String inServiceEmail)
{
this.inServiceEmail =
inServiceEmail;
}
public void setInServicePhone(String inServicePhone)
{
this.inServicePhone =
inServicePhone;
}
public void setInServicePostalAddress(String
inServicePostalAddress) {
this.inServicePostalAddress =
inServicePostalAddress;
}
}
Source code for Driver.java:
import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
Scanner scnr = new
Scanner(System.in);
// Instance variables
String name;
String type;
String gender = null;
int age = 0;
float weight = 0;
float tailLength = 0;
float height;
float
bodyLength;
String species =
null;
float
measurementOfTorso;
float
measurementOfSkull;
float
measurementOfNeck;
// Create New Dog
Dog dog1 = new Dog();
// Create New Monkey
Monkey monkey1 = new
Monkey();
// Method to process request for a rescue animal
// Method(s) to update information on existing
animals
// Method to add animals
System.out.println("Name of the animal?");
name = scnr.next();
System.out.println("Input YES if
the animal is a monkey or NO if the animal is a dog.");
type = scnr.next();
//if YES is typed then the monkey information will be
inputed
String newMonkey =
scnr.next();
if (newMonkey.equals("YES"))
{
System.out.println("What is the monkey's gender?");
gender = scnr.next();
System.out.println("What is the monkey's age?");
age = scnr.nextInt();
System.out.println("How much does the monkey weight?");
weight = scnr.nextFloat();
System.out.println("Input length of the monkey's tail?");
tailLength = scnr.nextFloat();
System.out.println("Input monkey's height.");
height = scnr.nextFloat();
System.out.println("Input monkey's body lenght.");
bodyLength = scnr.nextFloat();
System.out.println("What type of species is the monkey?");
species = scnr.next();
System.out.println("Input monkey's torso measurements.");
measurementOfTorso = scnr.nextFloat();
System.out.println("Input monkey's skull measurements");
measurementOfSkull = scnr.nextFloat();
System.out.println("Input monkey's neck measurements");
measurementOfNeck =
scnr.nextFloat();
//Prints out the monkey information sheet from
the inputed data
System.out.println("Animal Information");
System.out.println("Animal Type: Monkey");
System.out.println("Name: " +name);
System.out.println("Species: " +species);
System.out.println("Gender: " +gender);
System.out.println("Age: " +age);
System.out.println("Tail Length: " +tailLength);
System.out.println("Height: " +height);
System.out.println("Torso Measurement: "
+measurementOfTorso);
System.out.println("Skull Measurement: "
+measurementOfSkull);
System.out.println("Neck Measurement: " +measurementOfNeck);
}
// If NO is typed, input dog
information
String newDog = scnr.next();
if (newDog.equals("NO")) {
System.out.println("What is the dog's gender?");
gender = scnr.next();
System.out.println("What is the dog's age?");
age = scnr.nextInt();
System.out.println("How much does the dog weight?");
weight = scnr.nextFloat();
System.out.println("What type of species is the dog?");
species = scnr.next();
// Prints the dogs information that
was inputed
System.out.println("Animal
Information");
System.out.println("Animal Type:
Dog");
System.out.println("Name: "
+name);
System.out.println("Gender: "
+gender);
System.out.println("Age: "
+age);
System.out.println("Species: "
+species);
}
}
}
I have done a decent amount of coding... but I need you to help me understand...
I have completed a large portion of this work... but I don't know if it is good enough. Please look it over and give me any advice, tips, critiques, etc. I think I may need more constructors. Here are the directions to this portion: Before you begin modifying and creating classes, your team lead reminds you to demonstrate industry standard best practices in all your code to ensure clarity, consistency, and efficiency among all software developers working on the program....
Assignment (to be done in Java): Person Class: public class Person extends Passenger{ private int numOffspring; public Person() { this.numOffspring = 0; } public Person (int numOffspring) { this.numOffspring = numOffspring; } public Person(String name, int birthYear, double weight, double height, char gender, int numCarryOn, int numOffspring) { super(name, birthYear, weight, height, gender, numCarryOn); if(numOffspring < 0) { this.numOffspring = 0; } this.numOffspring = numOffspring; } public int getNumOffspring() { ...
Language: C++ Create an abstract base class person. The person class must be an abstract base class where the following functions are abstracted (to be implemented in Salesman and Warehouse): • set Position • get Position • get TotalSalary .printDetails The person class shall store the following data as either private or protected (i.e., not public; need to be accessible to the derived classes): . a person's name: std::string . a person's age: int . a person's height: float The...
public class Fish { private String species; private int size; private boolean hungry; public Fish() { } public Fish(String species, int size) { this.species = species; this.size = size; } public String getSpecies() { return species; } public int getSize() { return size; } public boolean isHungry() { return hungry; } public void setHungry(boolean hungry) { this.hungry = hungry; } public String toString() { return "A "+(hungry?"hungry":"full")+" "+size+"cm "+species; } }Define a class called Lake that defines the following private...
How to create a constructor that uses parameters from different classes? I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer. I have to create an object like the example below....... PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams", "Los Angeles, CA", "3235331234", 933, true, 400); System.out.println(preferredcustomer1.toString() + "\n"); public class Person { private String name; private String address; private long...
java questions: 1. Explain the difference between a deep and a shallow copy. 2. Given the below classes: public class Date { private String month; private String day; private String year; public Date(String month, String day, String year) { this.month = month; this.day = day; this.year = year; } public String getMonth() { return month; } public String getDay() { return day; } public String...
Write in java and the class need to use give in the end copy it is fine. Problem Use the Plant, Tree, Flower and Vegetable classes you have already created. Add an equals method to Plant, Tree and Flower only (see #2 below and the code at the end). The equals method in Plant will check the name. In Tree it will test name (use the parent equals), and the height. In Flower it will check name and color. In...
public enum Rating { GENERAL(0), PARENTALGUIDANCE(1), MATURE(2); private int minAge; private Rating(int i) { minAge = i; } public int getMinAge() { return minAge; } public void setMinAge(int age) { minAge = age; } public String toString() { switch(this) { case GENERAL: return "G"; case PARENTALGUIDANCE: return "P"; case MATURE: return...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
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...