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

The most basic form of the sine function of time () is: y(t)-Asin (2 ft+?)-Asin

ID: 3702866 • Letter: T

Question

The most basic form of the sine function of time () is: y(t)-Asin (2 ft+?)-Asin ( t+?) {displaystyle y(t)=A'sin(2tp? ft+ arphi -Alsin omega t+varphi) o)-Asintr+) «A-the amplitude, the peak deviation of the function from zero. the phase, when j ? {displaystyle arphi } s non- : zero, the entire waveform appears to be shifted in time. Se C++ 3 Define a struct called Point with components xCoordinate and yCoordinate Define a class Shape with the public pure vi void draw0 const 0. Define the five classes Wave0, Wavel, Wave2, Wave3, Wave4 which publicly inherits the class Shape and each has the public member function void draw0 const. rtual function virtual Implement the member function draw) of each class using some phase and some amplitude. Enforce the principle of least privileged. Use the given driver to produce the following output:

Explanation / Answer

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

#include<math.h>

struct Point

{

int xCoordinate, yCoordinate;

};

void printGraph(int x, int y)

{

initwindow(800,600);

line(0,300,getmaxx(),300);

line(400,0,400,getmaxy());

float pi = 3.14;

for(int i = -360; i < 360 ; i++)

{

x = (int) 400+i;

y = (int) 300 - sin(i*pi/100)*25;

putpixel(x,y,WHITE);

}

getch();

closegraph();

}

class Shape

{

public:

virtual void draw() const = 0;

}

class Wave0 : public Shape

{

public:

Point p0;

cout<<"Enter phase : ";

cin>>p0.xCoordinate;

cout<<" Enter amplitude : ";

cin>>p0.yCoordinate;

printGraph(p0.xCoordinate,p0.yCoordinate);

}

class Wave1 : public Shape

{

public:

void implementation()

{

Point p1;

cout<<"Enter phase : ";

cin>>p1.xCoordinate;

cout<<" Enter amplitude : ";

cin>>p1.yCoordinate;

printGraph(p1.xCoordinate,p1.yCoordinate);

}

}

class Wave2 : public Shape

{

public:

void implementation()

{

Point p2;

cout<<"Enter phase : ";

cin>>p2.xCoordinate;

cout<<" Enter amplitude : ";

cin>>p2.yCoordinate;

printGraph(p2.xCoordinate,p2.yCoordinate);

}

}

class Wave3 : public Shape

{

public:

void implementation()

{

Point p3;

cout<<"Enter phase : ";

cin>>p3.xCoordinate;

cout<<" Enter amplitude : ";

cin>>p3.yCoordinate;

printGraph(p3.xCoordinate,p3.yCoordinate);

}

}

class Wave4 : public Shape

{

public:

void implementation()

{

Point p4;

cout<<"Enter phase : ";

cin>>p.xCoordinate;

cout<<" Enter amplitude : ";

cin>>p.yCoordinate;

printGraph(p4.xCoordinate,p4.yCoordinate);

}

}

void main()

{

Wave0 w0;

Wave1 w1;

Wave2 w2;

Wave3 w3;

Wave4 w4;

w0.implementation();

w1.implementation();

w2.implementation();

w3.implementation();

w4.implementation();

}

// 1. Roughly this is the algorithm that needs to be followed.

// 2. There may be some implementation problems based on compiler, hence output may or may not differ.

// 3. As far as I could understand the question, I solved it. I hope I have answered your question.

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote