Hi im new in need of help!
Hi everyone! Im new at his forum and I need some help with this assignmnent I have! Just so you have an idea, I am NOT a computer science major...and I have no idea of what Im doing so help is appreciated!
My assignment is the "Diamond" assignment and I already have the code done! but one last thing i have to do... to write a class. To be more specific.. ''
Write a class called Diamond. Have the appropriate data members for that class. Also have a constructor and a function to output the diamond."
This is my code in .cpp
Code:
#pragma once
class Diamond
{
public:
Diamond(void);
~Diamond(void);
};
#include "stdafx.h"
#include<iostream>
using namespace std;
int main(){
int n,i,j; //integer
char symbol; //character
cout<<"Enter the character, and length: ";
cin>>symbol;
cin>>n;
if(n %2 ==0 || n<0 || n >21) // indicates the number has to be even, greater than 0 and less than 21
{
do{
cout<<"You have entered an illegal value for the length. It must be between 1 and 21.";
cin>>n;
}
while(n %2 ==0 || n<0 || n >21); // the do will run if this condition is followed
}
for(i=0;i<n/2;i++) // range for the loop
// number of rows divided by 2 and increased by 1
{
for(j=n/2-i;j>=0;j--)
cout<<" "; // output blank space
cout<<symbol; // output character intered
for(j=1;j<=2*i;j++)
cout<<" ";
if(i>0)
cout<<symbol;
cout<<endl;
}
for(i=n/2;i>=0;i--)
{
for(j=n/2-i;j>=0;j--)
cout<<" ";
cout<<symbol;
for(j=1;j<=2*i;j++)
cout<<" ";
if(i>0)
cout<<symbol;
cout<<endl;
}
system("pause");
}
I suck at classes.... any idea on how to do it?
Thank you!