Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Author the C++ class (both a .h file and a .cpp file) represented by the UML Cla

ID: 3560125 • Letter: A

Question

Author the C++ class (both a .h file and a .cpp file) represented by the UML Class Diagram shown below. Create getter and setter methods shown below that interact with the private members with matching names.

JuryTrial JuryTrial( string location, string accused, string crime );

string getLocation(); // getter methods
string getAccused();
string getCrime();

void setLocation( string location ); // setter methods
void setAccused( string accused );
void setCrime( string crime ); string my_Location; // the location of the trial...
string my_Accused; // name of the accused on trial...
string my_Crime; // the crime that is on trial...

Explanation / Answer

#include<iostream>
using namespace std;
// Save as JuryTrial.h
class JuryTrial
{
public:
JuryTrial( string location, string accused, string crime );
string getLocation(); // getter methods
string getAccused();
string getCrime();
void setLocation( string location ); // setter methods
void setAccused( string accused );
void setCrime( string crime );
private:
string my_Location; // the location of the trial...
string my_Accused; // name of the accused on trial...
string my_Crime; // the crime that is on trial...
};

// Save as JuryTrial.cpp
#include<string>
#include "JuryTrial.h"
using namespace std;
JuryTrial::JuryTrial( string location, string accused, string crime )
{
setLocation(location);
setAccused(accused);
setCrime(crime);
}
string JuryTrial::getLocation() // getter methods
{
return my_Location;
}
string JuryTrial::getAccused()
{
return my_Accused;
}
string JuryTrial::getCrime()
{
return my_Crime;
}
void JuryTrial::setLocation( string location ) // setter methods
{
my_Location = location;
}
void JuryTrial::setAccused( string accused )
{
my_Accused = accuse;
}
void JuryTrial::setCrime( string crime )
{
my_Crime = crime;
}