Write an application that combines several classes and interfaces.

Answers

Answer 1

Answer:

Explanation:

The following program is written in Java and it combines several classes and an interface in order to save different pet objects and their needed methods and specifications.

import java.util.Scanner;

interface Animal {

   void animalSound(String sound);

   void sleep(int time);

}

public class PetInformation {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);

       String petName, dogName;

       String dogBreed = "null";

       int petAge, dogAge;

       Pet myPet = new Pet();

       System.out.println("Enter Pet Name:");

       petName = scnr.nextLine();

       System.out.println("Enter Pet Age:");

       petAge = scnr.nextInt();

       Dog myDog = new Dog();

       System.out.println("Enter Dog Name:");

       dogName = scnr.next();

       System.out.println("Enter Dog Age:");

       dogAge = scnr.nextInt();

       scnr.nextLine();

       System.out.println("Enter Dog Breed:");

       dogBreed = scnr.nextLine();

       System.out.println(" ");

       myPet.setName(petName);

       myPet.setAge(petAge);

       myPet.printInfo();

       myDog.setName(dogName);

       myDog.setAge(dogAge);

       myDog.setBreed(dogBreed);

       myDog.printInfo();

       System.out.println(" Breed: " + myDog.getBreed());

   }

}

class Pet implements Animal{

   protected String petName;

   protected int petAge;

   public void setName(String userName) {

       petName = userName;

   }

   public String getName() {

       return petName;

   }

   public void setAge(int userAge) {

       petAge = userAge;

   }

   public int getAge() {

       return petAge;

   }

   public void printInfo() {

       System.out.println("Pet Information: ");

       System.out.println(" Name: " + petName);

       System.out.println(" Age: " + petAge);

   }

   //The at (email symbol) goes before the Override keyword, Brainly detects it as a swearword and wont allow it

   Override

   public void animalSound(String sound) {

       System.out.println(this.petName + " says: " + sound);

   }

//The at (email symbol) goes before the Override keyword, Brainly detects it as a swearword and wont allow it

  Override

   public void sleep(int time) {

       System.out.println(this.petName + " sleeps for " + time + "minutes");

   }

}

class Dog extends Pet {

   private String dogBreed;

   public void setBreed(String userBreed) {

       dogBreed = userBreed;

   }

   public String getBreed() {

       return dogBreed;

   }

}

Write An Application That Combines Several Classes And Interfaces.

Related Questions

Parts of a computer software

Answers

Answer:

I think application software

utility software

networking software

What are some examples and non-examples of digital security?

Answers

Answer:

Devices such as a smart card-based USB token, the SIM card in your cell phone, the secure chip in your contactless payment card or an ePassport are digital security devices

Other Questions
need help writing a Conclusion just that. This is what I got so far And need to look something like this the example is my teachers how was the oil crisis resolved? In recent decades, lobbying has become a powerful force in the political world.Lobbyists frequently meet behind closed doors with senators, lawmakers, andcongressmen and women to push influential legislation through the congressionalprocess. VWhich sociological perspective would be most interested in examiningthe lobbying movement? Why? Which of the following patients should be admitted as an inpatient at ahospital?A. Katie's having her tonsils removed and will be able to go homeshortly after she wakes up from surgery.B. Phil's having his blood sugar tested and having his annualphysicalc. Salvatore's having a hip transplant and will need to be closelymonitored for a week.D. Chen's having chest X-rays taken to determine if he has a brokenrib.SUBMIT PLEASE ANSWER IVE BEEN UP SINCE YESTERDAY APPARENTLY AND ITS 2:19 A.M. I am tired and TRYING TO get stuff finished. PRONTOIn a Notes:TM document, your reactions to the text appear in the right-hand column appear in the left-hand column are written in the center of the page are written in the margins of the text Can you define these words?? Thanks!CelluloseChlorophyllChloroplastBryophytePterophyteGymnospermConeAngiospermFlowerCuticleVascular tissueXylemPhloemRootsRoot hairsStemsLeavesPhotosynthesis 1. I can hear the steakon the hot plate.(1) brewing(2) thundering (3) sizzling(4) hissing2. Please(1) sealthe curtains - it is getting too bright.(2) draw(3) lift(4) close()3. The bright(1) hydrogensigns on the streets have attracted my attention.(2) helium(3) rainbow(4) neon()(4)4. He is very particular about personal(1) brightness (2) hygiene(3) spotless(4) hype( )5. I use a wooden(1) cupto make mooncakes.(2) mould(3) cutter(4) shape6. I can hear the patientin pain.(1) mumbling (2) grumbling (3) moaning(4) groaning( )7. The dessert for today is strawberry(1) mousse(2) ice(3) cream(4) gel)8. She(1) performedaround the office with her new outfit.(2) showed (3) paraded(4) sashayed(9. She is so fascinated by the(1) exotic(2) tropicalEast that she eagerly devours books on it.(3) elusive(4) erotic(10. It seems that a conflict between the two parties is(1) inevitable (2) evident (3) unapproachable (4) indefinite11. She is still infor her father so she wears black all the time.(1) remembrance (2) admiration (3) moaning (4) mourning(12. Theresa has been over what to do with the illegitimate baby.(1) cracking (2) considering (3) worrying (4) agonising If x3=125 and y3=8, what is the value of yx Why did no American president in the 18th and 19th centuries serve for more than two terms? state 3 reasons why should teenagers read newspapers or listen to the news #6"Poem" is a free verse poem because it _____.contains no imageryuses elaborate languageendorses a political themehas no fixed rhyme or meter infection can be spread through:a) blood and certain body fluids.b) airborne droplets.c) both of the above Randy is playing a number game. Beginning with the number 6, he adds 4, multiples by5, and then divides by -10. He then subtracts 2. What number does he find at the end ofthe game?A. -7B. -3.6C. -4.6D. -5 Check the pic pleaseWith steps please How could a change in the DNA sequence of a single gene affect an organism?The organism would likely no longer be able to produce offspring.The gene could code for carbohydrates instead of proteins.The function of a protein encoded by the gene could change.DNA could change into RNA.Previous Helpppppppppppppppppppppp The economy is in long-run equilibrium. Technological change shifts the long-run aggregate supply curve $120 billion to the right. At the same time, government purchases increase by $30 billion. If the MPC equals 0.8 and the crowding-out effects are $30 billion, we would expect that in the long run. (C)a. real GDP would be higher but the price level would be lowerb. both real GDP and the price level would be lowerc. real GDP would be higher but the price level would be the samed. both real GDP and the price level would be higher what is the least common denominator of 1/2, 2/3, and 3/8 The lengths of diagonals of a rectangle are representedby 5x yards and 7x - 18 yards. Find the length of eachdiagonal. Geometry Transversals simple answer needed