Implementing Constructs

I just want to say first that this is a lab exercise and I am in no way asking for an answer, I just need a little bit of help getting started. I missed my lab last week because I was sick and I just don't have the slightest idea how to go about starting this exercise that being said here is a snippet of code and part of the exercise. If anyone could get me going I would highly appreciate it.

Your task in this lab exercise will be to complete the header, to implement a file Resistor.cpp to go with it, and finally to use the resultant Resistor class to perform some electrical calculations.

The Resistor class represents more than merely a resistor’s resistance. It also represents in watts the resistor’s power rating, which is the maximum power the resistor can dissipate without melting (and perhaps without posing certain additional risks, such as lighting nearby materials aflame under test conditions). It further carries a safety factor, which represents the fraction of rated power the engineer is willing to risk in operation: the safety factor defaults to 1.0 (full power allowed, no margin for safety) but can be set to a smaller, safer number if desired.


Here is some code from the header file I'm just not sure where he wants me to go with this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

namespace Electronic {
	class Resistor;
	Resistor parallel( Resistor, Resistor );
	Resistor series( Resistor, Resistor );
}

class Electronic::Resistor {

	private:

// Your code goes here.

	public:

		// Exceptions.
		class Exc_nonsensical_safety_factor {};
		class Exc_risk_of_overcurrent {};
		class Exc_overcurrent : public Exc_risk_of_overcurrent {};

		// Constructors.
		Resistor( double voltage0, double current0 );

		// Informational methods.
		double resistance() const;
		double power_rating() const;
		double safety_factor() const;

		// Other constant methods.
		double current( double voltage0 ) const;
		double voltage( double current0 ) const;

		// Nonconstant, object-altering methods.
		void set_safety_factor( double );

};

Topic archived. No new replies allowed.