Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.newExercise;
- public class Dog { //Opening class
- // Property definition
- private String name;
- // Default-ен конструктор
- public Dog( ) {
- this.name = "Sharo";
- }
- // Конструктор с параметри
- public Dog(String name) {
- this.name = name;
- }
- // Get method
- public String getName() {
- return this.name;
- }
- // Set method
- public void setName(String name) {
- this.name = name;
- }
- // Custom method - които ние създаваме
- public void bark( ) {
- System.out.printf("Dog %s said: Wow-wow!%n", name);
- }
- }//Closing class
Advertisement
Add Comment
Please, Sign In to add comment