Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Q1: Imagine that you want to keep track of your pet fish Each fish is a certain kind and has a two-part name. For example,
Q1: Imagine that you want to keep track of your pet fish Each fish is a certain kind and has a two-part name. For example, your clownfish is named Nemo Finding. Y ou want to see whether any two given fish are the same kind Y ou also want to know how many fish you have. Design, implement, and demonstrate a class Fish that meets the previous requirements. Include UML diagram that gives only the class names and the associations between them Document each method with comments in javadoc format Implement a class called Name to represent a fish's pet name. Some of your methods and constructors must have object parameter of type class. SAMPLE OUTPUT: Test tostuing(): Nemo Finding (clownish) Test getName(), getType(), and getNumberOfFish(: My name is Nemo Finding, I am a clownfish fish There are 3 fish in the tank Test isSameType(): Nemo Finding (clownish) and Bozo Iron (clownfish) are the same type of fish Nemo Finding (clownfish) and Patrick Star (starfish) are different types of fish Press any key to continue... Q2: Write a class named PhoneBook that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then wite a program that creates at least five PhoneBook objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList. Q3: a Wite a class named Inventory that has fields (instance variable) for item description and a unit number. The class should have three constructors and appropriate accessor and mutator methods. First constructor is no-argument constructor. The second constuctor accepts a String argument which is assigned to the description field The third constzuctor accepts a String argument which is assigned to the description field, and an int argument which is assigned to the unit's field Then write a program that creates four Inventory objects and stores them in an Array. Also, wite getItemsinfo method which accepts an Inventory array as an argument. In this method the user enters data for each Inventory object. Use a loop to display the contents of each object in the Array. b- In the main method, use the same class inventory form Q3 (a) to create three inventory objects. The first inventory object has 10 umits, the second inventory object has 20 units and the third object has 30 units. Assign different string arguments to the description field of those three inventory objects. Write a method called totUnits which takes variable number arguments of Inventory objects and retums the total of their umits. Call method totUnits with one argument, then with two arguments and finally with three arguments. Display the retumed value after each method call. Q4: (Using the Enhanced for Statement) Write an application that uses an enhanced for statement to sum the double values passed by the command-line arguments [Hint Use the static method parseDouble of class Double to convert a String to a double value.] Q1: Imagine that you want to keep track of your pet fish Each fish is a certain kind and has a two-part name. For example, your clownfish is named Nemo Finding. Y ou want to see whether any two given fish are the same kind Y ou also want to know how many fish you have. Design, implement, and demonstrate a class Fish that meets the previous requirements. Include UML diagram that gives only the class names and the associations between them Document each method with comments in javadoc format Implement a class called Name to represent a fish's pet name. Some of your methods and constructors must have object parameter of type class. SAMPLE OUTPUT: Test tostuing(): Nemo Finding (clownish) Test getName(), getType(), and getNumberOfFish(: My name is Nemo Finding, I am a clownfish fish There are 3 fish in the tank Test isSameType(): Nemo Finding (clownish) and Bozo Iron (clownfish) are the same type of fish Nemo Finding (clownfish) and Patrick Star (starfish) are different types of fish Press any key to continue... Q2: Write a class named PhoneBook that has fields for a person's name and phone number. The class should have a constructor and appropriate accessor and mutator methods. Then wite a program that creates at least five PhoneBook objects and stores them in an ArrayList. Use a loop to display the contents of each object in the ArrayList. Q3: a Wite a class named Inventory that has fields (instance variable) for item description and a unit number. The class should have three constructors and appropriate accessor and mutator methods. First constructor is no-argument constructor. The second constuctor accepts a String argument which is assigned to the description field The third constzuctor accepts a String argument which is assigned to the description field, and an int argument which is assigned to the unit's field Then write a program that creates four Inventory objects and stores them in an Array. Also, wite getItemsinfo method which accepts an Inventory array as an argument. In this method the user enters data for each Inventory object. Use a loop to display the contents of each object in the Array. b- In the main method, use the same class inventory form Q3 (a) to create three inventory objects. The first inventory object has 10 umits, the second inventory object has 20 units and the third object has 30 units. Assign different string arguments to the description field of those three inventory objects. Write a method called totUnits which takes variable number arguments of Inventory objects and retums the total of their umits. Call method totUnits with one argument, then with two arguments and finally with three arguments. Display the retumed value after each method call. Q4: (Using the Enhanced for Statement) Write an application that uses an enhanced for statement to sum the double values passed by the command-line arguments [Hint Use the static method parseDouble of class Double to convert a String to a double value.]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started