Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company.newExercise;
- import java.util.Scanner;
- public class Start { //Start of class
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.println("Write first dog's name: ");
- String firstDogName = scan.nextLine();// Read the first name of the dog
- Dog firstDog = new Dog(firstDogName); //Create the first dog with parameters
- System.out.println("Write second dog's name: ");
- String secondDogName = scan.nextLine(); // Read the second name of the dog
- Dog secondDog = new Dog(); //Create the second dog with default - constructor with default name Sharo
- secondDog.setName(secondDogName); //Change name of the second dog
- Dog thirdDog = new Dog(); //Create the third dog with default - constructor with default name Sharo
- Dog[] dogsArray = new Dog[]{firstDog, secondDog, thirdDog};
- for (Dog tempDog : dogsArray) {
- tempDog.bark();
- }
- }
- }//End of class
Advertisement
Add Comment
Please, Sign In to add comment