Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myApp;
- public class Adult {
- /* Properties */
- private String name, profession;
- private double height;
- /* Get, Set Methods */
- public String getName() {
- return this.name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getProfession() {
- return this.profession;
- }
- public void setProfession(String profession) {
- this.profession = profession;
- }
- public double getHeight() {
- return this.height;
- }
- public void setHeight(double height) {
- this.height = height;
- }
- /* Constructors */
- public Adult(String name, double height, String profession) {
- this.name = name;
- this.height = height;
- this.profession = profession;
- }
- public Adult(String name, double height) {
- this(name, height, "");
- }
- public Adult(Adult adultObject) {
- this.name = adultObject.name;
- this.profession = adultObject.profession;
- this.height = adultObject.height;
- }
- /* Methods */
- public void showSummary() {
- System.out.printf("(%s) %s is %.2fcm%s%n",
- this, name, height, profession.equals("")?"":(", and is a "+profession));
- }
- }
Add Comment
Please, Sign In to add comment