Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Language: Java [1pts] Create a class Dog that has the following members (attributes) String name Integer age And only the following constructors public Dog(String name,

image text in transcribedLanguage: Java

[1pts] Create a class Dog that has the following members (attributes) String name Integer age And only the following constructors public Dog(String name, Integer age) [2pts] Create a class Person that has the following members String name Integer age Optional dog And has only the following constructors public Person (String name, Integer age) //should call the below constructor public Person (String name, Integer age, Dog dog) and implements the following methods [3pts] public bool hasoldDog() { //should return true IF Person has a Dog AND Dog.age >=10 //lose 1 point if you use an If statement } [3pts] public void changeDogsName(String newName) { // should change the Persons Dog's name to the new Name If the person has a Dog //or it should throw a RuntimeException(this.name + " does not own a dog!") // if the person does not own a dog //lose 1 point if you use an If statement } [3pts] Create a Java application class (class with a main method) that Initializes a Person class without a dog - Tries to change the person's dogs name, catches the exception throw by changeDogsName and outputs "Unable to change dogs name" + exception message [8pts] Write Unit tests for Dog and Person Class -Each unit tests must have at least assert -Some method may require more than one test, e.x you would want to test changeDogsName on a person that has a dog, as well as a person that does not have a dog *note Dog and Person should implement the standard Setters/Getters/Equals method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

What is Entrepreneur?

Answered: 1 week ago

Question

Which period is known as the chalolithic age ?

Answered: 1 week ago