Computer Science Homework Solutions
Problem
#26068

Java Programming

See attach files.  I am having a hard time to figure out how to display the output.  I was trying to use the my.displayInformation(); clause but wasnt sucessful.  Any help would be greatly apperciated.

Write a Java program that does the following:
1. Creates a Ball class with attributes for color, hardness, and size and instantiates the following Ball objects: golf, baseball, soccer.
2. Creates a display method which can print the current state of the attributes for all objects.
3. Creates attributes that have default values (your choice) which will display to the screen when the program is run and then each of the attributes for each object will be changed (your choice) during the program run and printed again to the screen with the appropriate message so that I can tell what the original values were and how they were changed during the program run.
Your output should be as follows:
A. Print each ball type's default attribute values i.e., "The golf ball color = white, hardness = hard, and size = small"
B. Change each ball type's default attribute values and print the changes i.e., "The golf ball is now color = orange, hardness = soft, and size = large."

Solution
What is this?
By OTA - Overall OTA Rating
Huanhuan Liang, MSc - 4.8/5
Purchase Cost Now
$2.19 CAD (was ~$19.95)
Included in Download
  • Plain text response
  • Attached file(s):
    • answer.doc
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • C++ Programming - A CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Its child, LabCourse, includes one more field that holds a lab fee charged in addition to the ...
  • Computer Programming - Explain the concept of object orientation and Universal Modeling Language (UML) as used in computer programming. How do programmers use class, attributes, and methods in computer programming to so ...
  • Programming - Should there be a single programming language for all programming domains? Explain why or why not.
  • C++ Programming and UML - Create a class named MusicalComposition that contains fields for title, composer, and year written. Include a constructor that requires all three values and a appropriate display function. The child ...
  • Is Object Oriented programming approach better than the structural programming approach? Which of them is a natural choice? - Discuss why the object oriented programming paradigm is considered a better choice than the structured programming paradigm. Does it reflect our "natural" way of thinking or do you find it artificial?
Browse