Question

Part 1 Understand the Problem and Class Design with UML The client needs a program to...

Part 1 Understand the Problem and Class Design with UML

  • The client needs a program to calculate the age of a tuna fish. The program must store the length of the fish in cm, and the weight of the fish in pounds. To calculate the estimated age of the fish in years multiply the length times the weight then divide by 10000. Design a class based on this word problem.
  • Testing values are 300 cm length, and 1111.12 pounds.

  • Using the word problem above, design a class with the needed fields, one default (no parameter) constructor, and needed methods. Document your design using a detailed UML Class diagram.
  • Note: The calculations used in this word problem are fictional.

Homework Answers

Answer #1

UML Diagram:

  • The class consists of private members for length and weight which are of double data type
  • The class has a default constructor i.e no-argument constructor that sets the length and weight to default values of 0.
  • mutator method setLength that takes as input the length of fish and sets the field length to the specified value.
  • mutator method setWeight that takes as input the weight of the fish and sets the field weight to the specified value.
  • accessor method getLength that returns the value of length of the fish
  • accessor method getWeight that returns the value of the weight of the fish
  • method getAge to calculate and return the age of the fish in years and hence returns int
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
c++ program. can you please do commenting. Question 1 [25]. (The Account Class) Design a class...
c++ program. can you please do commenting. Question 1 [25]. (The Account Class) Design a class named Account that contains (keep the data fields private): a) An int data field named id for the account. b) A double data field named balance for the account. c) A double data field named annualInterestRate that stores the current interest rate. d) A no-arg constructor that creates a default account with id 0, balance 0, and annualInterestRate 0. e) The accessor and mutator...
Design a Java class named Polygon that contains:  A private int data field named numSides...
Design a Java class named Polygon that contains:  A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4.  A private double data field named sideLength that defines the length of each side. The default value should be 5.0.  A private double data field named xCoord that defines the x-coordinate of the center of the polygon. The default value should be 0.0.  A private double...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT