Explore BrainMass
Share

Designing a class

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

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!!!!!!!!!!!!!!!!

© BrainMass Inc. brainmass.com October 25, 2018, 12:34 am ad1c9bdddf
https://brainmass.com/computer-science/programming-languages/designing-class-232563

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 ...

Solution Summary

The expert designs a programming unit called a class.

$2.19
See Also This Related BrainMass Solution

Instructional Tools and ISD / Computer-Based Learning and Design

Part 1

Define instructional media and discuss its purpose. Address these questions:

Where does instructional media fit in the instructional systems design (ISD) process?

In the ISD process, when do you select instructional media?

What criteria do you use to select appropriate instructional media?

Based on your field, discuss some real-world applications of instructional media.

Part 2

Provide a summary of your thoughts on the role of computers in an education and/or training environment. Specifically, more about stand-alone computer-based applications for learning (such as computer labs, workplace computers, or home computer) and networked computer-based applications (such as online courses) for distributed learning.

View Full Posting Details