Review the overall structure of the code, and then go through each of the classe
ID: 3688337 • Letter: R
Question
Review the overall structure of the code, and then go through each of the classes and add comments and comment blocks. Your goal is to add sufficient comments so that someone unfamiliar with the code (but familiar with Java) could understand generally what is going on. At a minimum, there should be a code block above every function, and a block at the top of each Java file.
package main;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleStringProperty;
public class Employee {
public Employee(String name, float salary){
this.name = new SimpleStringProperty(name);
this.salary = new SimpleFloatProperty(salary);
}
public String getName() {
return name.get();
}
public SimpleStringProperty nameProperty() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
public float getSalary() {
return salary.get();
}
public SimpleFloatProperty salaryProperty() {
return salary;
}
public void setSalary(float salary) {
this.salary.set(salary);
}
private SimpleStringProperty name;
private SimpleFloatProperty salary;
}
Explanation / Answer
package main;
/*importing packages with specified SimpleFloatProperty, SimpleStringProperty classes*/
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleStringProperty;
//creating class Employee
public class Employee {
//constructor with two parameters string and float data types
public Employee(String name, float salary){
this.name = new SimpleStringProperty(name);
this.salary = new SimpleFloatProperty(salary);
}
//getname method written type string
public String getName() {
return name.get();
}
//creating nameProperty method return type SimpleStringProperty object
public SimpleStringProperty nameProperty() {
return name;
}
//setName() with String parameter argument return nothing
public void setName(String name) {
this.name.set(name);
}
//getSalary() return type float
public float getSalary() {
return salary.get();
}
//creating salaryProperty() with return type SimpleFloatProperty object
public SimpleFloatProperty salaryProperty() {
return salary;
}
//cearting setSalary() with float type argument and return nothing
public void setSalary(float salary) {
this.salary.set(salary);
}
//creating name object of SimpleStringProperty class with private modifier
private SimpleStringProperty name;
//creating salary object SimpleFloatProperty class with private modifier
private SimpleFloatProperty salary;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.