Data Structures and Objects - Lecture Notes | CS 145, Study notes of Computer Science

Material Type: Notes; Professor: Ehlmann; Class: Introduction to Computing for Engineers; Subject: Computer Science; University: Southern Illinois University Edwardsville; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-fve-1
koofers-user-fve-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Notes—Chap. 6b Data Structures and Objects
(pp. 227 – 242)
- Sections 6.3 and 6.4 present the object-oriented analysis, object-oriented
design, and object implementation of a Drill object.
- Object-oriented analysis is the process required to identify the attributes and
behaviors required for one or more classes of objects that are needed in the
developments of some application.
- Object-oriented design is the process required to determine for these
classes the appropriate names and types to represent the attributes and the ,
appropriate function and operator prototypes and algorithms to represent the
behaviors and the appropriate accessibilities.
- Will cover the author's implementation of the Drill class (with revisions):
#include <iostream>
using namespace std;
const double PI = 3.141592654;
class Drill {
public:
Drill()
// Create an uninitialized drill.
{}
Drill(double d, // diameter of drill bit in mm
double f, // feed rate in mm per revolution
double s // rotational speed in revolutions per minute (rpm)
);
// Create a drill with the given diameter, feed, and speed.
double mrr() const;
// Return drill's material removal rate in mm^3/sec.
double torque(double up // unit power dissipated in cutting
// a workpiece material (W . s/mm^3)
) const;
// Return the torque on drill given dissipated unit power up.
private:
double diameter, // diameter of drill bit in mm
feed, // feed rate in mm per revolution
speed; // rotational speed in revolutions per minute (rpm)
pf3

Partial preview of the text

Download Data Structures and Objects - Lecture Notes | CS 145 and more Study notes Computer Science in PDF only on Docsity!

Notes—Chap. 6b Data Structures and Objects

(pp. 227 – 242)

- Sections 6.3 and 6.4 present the object-oriented analysis , object-oriented

design , and object implementation of a Drill object.

- Object-oriented analysis is the process required to identify the attributes and

behaviors required for one or more classes of objects that are needed in the

developments of some application.

- Object-oriented design is the process required to determine for these

classes the appropriate names and types to represent the attributes and the ,

appropriate function and operator prototypes and algorithms to represent the

behaviors and the appropriate accessibilities.

- Will cover the author's implementation of the Drill class (with revisions):

#include using namespace std; const double PI = 3.141592654; class Drill { public: Drill() // Create an uninitialized drill. {} Drill(double d, // diameter of drill bit in mm double f, // feed rate in mm per revolution double s // rotational speed in revolutions per minute (rpm) ); // Create a drill with the given diameter, feed, and speed. double mrr() const; // Return drill's material removal rate in mm^3/sec. double torque(double up // unit power dissipated in cutting // a workpiece material (W. s/mm^3) ) const; // Return the torque on drill given dissipated unit power up. private: double diameter, // diameter of drill bit in mm feed, // feed rate in mm per revolution speed; // rotational speed in revolutions per minute (rpm)

friend istream& operator>> ( istream&, Drill& ); friend ostream& operator<< ( ostream&, const Drill& ); Why const? }; // class drill // Function and operator member (method) definitions: Drill :: Drill(double d, double f, double s) { diameter = d; feed = f; speed = s; } double Drill :: mrr() const { return (PI * 0.25 * diameter * diameter * feed * speed / 60.0); } double Drill :: torque(double unitPower) const { double radSec; // rotational speed in radians per second radSec = speed * 2 * PI / 60.0; return (unitPower * mrr() / radSec); } // Definitions of friend operators. istream& operator>> ( istream& is, Drill& dr ) // Extract from input stream is the three components of the Drill object dr // returning the updated input stream. { is >> dr.diameter >> dr.feed >> dr.speed; return is; } ostream& operator<< ( ostream& os, const Drill& dr ) // Display to the output scream os the drill object dr labeling all // components and returning the updated output stream. { os << "Drill " << endl << " diameter: " << dr.diameter << " mm" << endl << " feed: " << dr.feed << " mm/rev" << endl << " speed: " << dr.speed << " rpm" << endl; return os; } // // Driver to declare and manipulate a drill object // int main()