1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vivado [14]
3 years ago
5

The major objective of this lab is to practice class and object-oriented programming (OOP), and separate files: 1. We will reuse

lab 6, a direct current simulator with extensions to let you practice OOP. Pay special attention to the difference between procedural programming and OOP. 2. This is the first time you break a program into several files such that you do not need to have all functions included in one program. The idea of breaking a program into several files has many benefits that will be explained in lecture notes and ZyBook reading assignment. It is NOT the purpose of this lab to train your logical thinking capability. We select a simple problem to help you fully understand OOP and separate files in an efficient manner.
Computers and Technology
1 answer:
vovangra [49]3 years ago
8 0

Answer:

Implementation of resistor.cpp

#include "resistor.h"

Ohms::Ohm()

{

// default constructor

voltage=0;

}

Ohms::Ohm( double x) // parameterised constructor

{

voltage = x; // voltage x set to the supply voltage in the private data field called voltage

}

Ohms:: setVoltage(double a)

{

voltage = a;// to set supply voltage in private data field called voltage

}

Ohms::setOneResistance( String s, double p)

{

cin>>p; //enter the resistance value

if(p<=0) // if resistance is less than or equals to 0

return false

else // if re

cin.getline(s);

}

Ohms::getVoltage()

{

return voltage; //return voltage of ckt

}

Ohms::getCurrent()

{

return current; //return current of ckt

}

Ohms:: getNode()

{

return resistors; //return resistors of ckt

}

Ohms::sumResist()

{

double tot_resist = accumulate(resistors.begin(),resistors.end(),0); //std::accumulate function for calculating sum //of vectors and following are the starting and ending points

return tot_resist;

}

Ohms::calcCurrent()

{

if(current <=0) // if current is less than or equal to 0

return false;

else   // if current is greater than 0

return true;

}

Ohms:: calcVoltageAcross()

{

if(voltage<=0) // if voltage is less than or equal to 0

return false;

else //if voltage greater than 0

return true;

}

Explanation:

in the case of main.cpp its simple just make a class object and remember to include resistors.cpp with it for which the second last picture describes the process precisely. (Hint: Use theunit test case functions in the main.cpp).

As you can see node is a structure consisting of member variables, followed by a class Ohms representing a DC circuit.

By looking at these pictures, it is needed to implement the main.cpp and resistor.cpp files. The user defined header file resistor.h already consists of all contents of Class Ohm, struct node. You don't need to modify it in anyway in such case.

You might be interested in
Where does Reiner take eren after they have a fight?
Tom [10]

Answer:

So Reiner And Bertoldt wanted to take Eren and Ymir to Marley, a nation on the other side of the ocean so they can be devoured and there power can be given to a warrior canidate.

5 0
2 years ago
Read 2 more answers
When an organizatin needs a program to do a very specific job, it mayhire someone to write _____ software.​
Harman [31]
Code sofware your welcome
8 0
2 years ago
Any device that uses light to read and write information.
Ilya [14]
I think Optical Drive does.
8 0
2 years ago
Read 2 more answers
Which of the following statements is/are correct? a. At the network layer, entitlement can map identity and/or attributes to fun
AlekseyPX

Answer:

Option D

Explanation:

An Entitlement is an option to utilize, get to or devour an application or asset, commonly for a charge. For instance, a client may buy an Entitlement to utilize an application in ceaselessness (a "unending" permit), or they may buy a period restricted option to utilize an application, (for example, a one-year membership permit).

7 0
2 years ago
Why is peer answer always not working? just wondering idk why
Nady [450]
Wait.....What do you mean?
5 0
2 years ago
Read 2 more answers
Other questions:
  • Constructors ________. initialize instance variables when overloaded, can have identical argument lists when overloaded, are sel
    11·1 answer
  • Are there protections for people in terms of what data can be collected by different sites?
    10·1 answer
  • What natural resource are available on the coast but not somewhereelse
    13·1 answer
  • A network technician is designing a network for a small company. The network technician needs to implement an email server and w
    7·1 answer
  • Could someone please explain to me the an electrical circuit.
    13·2 answers
  • How are comments in a Java program treated by the compiler?
    14·2 answers
  • How is scale depicted on a flat video screen?
    13·1 answer
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
  • You have been on the phone with a user in a remote office for 30 minutes troubleshooting their minor desktop problem. No matter
    6·1 answer
  • If you give someone ______ to your device, they can control it through another phone or computer.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!