Purchase Solution

Designing a class

Not what you're looking for?

Ask Custom Question

Object oriented design is creating classes with both characteristics and behavior wrapped together (called encapsulation). Taking data (characteristics) and the functions (behavior) that operate on that data and storing them as one programming unit (called a class) is extremely powerful. When completing a class design it is critical to ask two very important questions: 1- What does it (the class) know (characteristics)? and 2- What can it (the class) do (behavior)? In chapter 3, fig 3.9 (p. 99) is the UML (Unified Modeling Language) class diagram for the GradeBook class in fig 3.7 (p. 95). This diagram answers the two questions above:
1. What does it know? It knows its course name (courseName).
2. What can it do?
a. It can set its course name if it's given a name (setCourseName(name : String))
b. It can get and return its course name (getCourseName() : String)
c. It can display a message (displayMessage())

Looking for another example, I just picked up the stapler on my desk. The following is a design for a stapler class by answering the two questions "What does it know?" and "What can it do?" Following that is the UML class diagram.

Stapler class:
1. What does it know?
a. It knows how many staples it has
b. It knows if its jammed
c. It knows its weight
2. What can it do?
a. It can reload, fill its staples to capacity
b. It can get an return whether it is jammed
c. It can staple, which decreases its number of staples by one
d. It can get and return its weight

Stapler
--------------------------
- totalStaples : integer
- jammed : Boolean
- weight: float
--------------------------
+ reload()
+ isJammed() : boolean
+ staple()
+ getWeight() : float

THE ABOVE IS JUST AN EXAMPLE:

Details of assignment: Choose an object from everyday life and design a class for it by answering the two questions and providing a UML class diagram. The subject of your post must be the name of your class. Mine would be Stapler. Your class must have a minimum of three characteristics and five behaviors.

THANKS!!!!!!!!!!!!!!!!

Purchase this Solution

Solution Summary

The expert designs a programming unit called a class.

Solution Preview

Hello student,
I have completed and attached the solution for posting.

Designing a class
Object oriented design is creating classes with both characteristics and behavior wrapped together (called encapsulation). Taking data (characteristics) and the functions (behavior) that operate on that data and storing them as one programming unit (called a class) is extremely powerful. When completing a class design it is critical to ask two very important questions: 1- What does it (the class) know (characteristics)? and 2- What can it (the class) do (behavior)? In chapter 3, fig 3.9 (p. 99) is the UML (Unified Modeling Language) class diagram for the ...

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.