قصد آموزش نداریم چون خیلی از سایت ها و کانال ها و پیج ها به بهترین شکل و به طور رایگان آموزش این زبان ها رو در اختیارتون قرار میدن
هدف ریز نکات و پروژه هایی ست که با این زبان ها انجام شدند
با قرار دادن سورس کد های آن ها و توضیح راجع به آن به یادگیری حرفه ای ( Intermediate ) می پردازیم
@de_coder
هدف ریز نکات و پروژه هایی ست که با این زبان ها انجام شدند
با قرار دادن سورس کد های آن ها و توضیح راجع به آن به یادگیری حرفه ای ( Intermediate ) می پردازیم
@de_coder
1.ساخت هرم
زبان نوشتاری JAVA
سطح سوال : بسیار آسان
*********//*********
// program to build pyramid with x in n stages
import java.util.Scanner;
public class pyramid
{
public static void main(String[] args) {
int i,n,m,k,j=1;
Scanner obj=new Scanner(System.in);
System.out.println("enter the no. stages in pyramid ");
System.out.println("u entered");
n=obj.nextInt();
System.out.println("ur beautiful Egypt pyramid is here");
m=n;
for(i=1;i<=n;i++)
{
while(j<m)
{
System.out.print(" ");
j++;
}
for(k=1;k<=i;k++)
{
System.out.print("x");
}
System.out.println(" ");
m=m-1;
j=1;
}
}
}
@de_coder
زبان نوشتاری JAVA
سطح سوال : بسیار آسان
*********//*********
// program to build pyramid with x in n stages
import java.util.Scanner;
public class pyramid
{
public static void main(String[] args) {
int i,n,m,k,j=1;
Scanner obj=new Scanner(System.in);
System.out.println("enter the no. stages in pyramid ");
System.out.println("u entered");
n=obj.nextInt();
System.out.println("ur beautiful Egypt pyramid is here");
m=n;
for(i=1;i<=n;i++)
{
while(j<m)
{
System.out.print(" ");
j++;
}
for(k=1;k<=i;k++)
{
System.out.print("x");
}
System.out.println(" ");
m=m-1;
j=1;
}
}
}
@de_coder
2. بازی کماندار در مقابل اُرگ
زبان نوشتاری ++C
سطح برنامه : متوسط
*********//*********
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
class hero
{
protected:
string name;
double life;
double attack;
double defense;
public:
virtual void myattack(hero&)=0;
double get_life() const
{
return this->life;
}
string get_name() const
{
return this->name;
}
double get_defense() const
{
return this->defense;
}
void set_life(double x)
{
this->life = x;
}
void set_attack(double x)
{
this->attack = x;
}
};
class orc : public hero
{
public:
orc() {
this->name = "Ushk";
this->life = 60;
this->defense = 25;
}
~orc(){}
void myattack (hero &h)
{
double aux;
cout<<this->name<<" made an Axe attack - ";
if(this->attack > h.get_defense())
{
aux = (this->attack - h.get_defense());
cout<< h.get_name() <<" received "<< aux <<" damage\n";
aux = h.get_life() - aux;
h.set_life(aux);
}
else
cout<<" **Attack miss** \n";
}
};
class archer : public hero
{
public:
archer(){
this->name = "Legolas";
this->life = 40;
this->defense = 10;
}
~archer(){}
void myattack (hero& h)
{
double aux;
cout<< this->name <<" throw an Arrow - ";
if(this->attack > h. get_defense())
{
aux = (this->attack - h.get_defense());
cout<< h.get_name() <<" received "<< aux <<" damage\n";
aux = h.get_life() - aux;
h.set_life(aux);
}
else
cout<<" **Attack miss**\n";
}
};
int main() {
srand(time(NULL));
orc orc1;
archer arch1;
double num;
while(1)
{
num = rand()%13+13;
orc1.set_attack(num);
orc1.myattack(arch1);
if(arch1.get_life() <= 0){
cout<<arch1.get_name()
<< " **Died**";
break;
}
num = rand()%30+23;
arch1.set_attack(num);
arch1.myattack(orc1);
if(orc1.get_life() <= 0){
cout<<orc1.get_name()
<<" **Died**";
break;
}
}
return 0;
}
@de_coder
زبان نوشتاری ++C
سطح برنامه : متوسط
*********//*********
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;
class hero
{
protected:
string name;
double life;
double attack;
double defense;
public:
virtual void myattack(hero&)=0;
double get_life() const
{
return this->life;
}
string get_name() const
{
return this->name;
}
double get_defense() const
{
return this->defense;
}
void set_life(double x)
{
this->life = x;
}
void set_attack(double x)
{
this->attack = x;
}
};
class orc : public hero
{
public:
orc() {
this->name = "Ushk";
this->life = 60;
this->defense = 25;
}
~orc(){}
void myattack (hero &h)
{
double aux;
cout<<this->name<<" made an Axe attack - ";
if(this->attack > h.get_defense())
{
aux = (this->attack - h.get_defense());
cout<< h.get_name() <<" received "<< aux <<" damage\n";
aux = h.get_life() - aux;
h.set_life(aux);
}
else
cout<<" **Attack miss** \n";
}
};
class archer : public hero
{
public:
archer(){
this->name = "Legolas";
this->life = 40;
this->defense = 10;
}
~archer(){}
void myattack (hero& h)
{
double aux;
cout<< this->name <<" throw an Arrow - ";
if(this->attack > h. get_defense())
{
aux = (this->attack - h.get_defense());
cout<< h.get_name() <<" received "<< aux <<" damage\n";
aux = h.get_life() - aux;
h.set_life(aux);
}
else
cout<<" **Attack miss**\n";
}
};
int main() {
srand(time(NULL));
orc orc1;
archer arch1;
double num;
while(1)
{
num = rand()%13+13;
orc1.set_attack(num);
orc1.myattack(arch1);
if(arch1.get_life() <= 0){
cout<<arch1.get_name()
<< " **Died**";
break;
}
num = rand()%30+23;
arch1.set_attack(num);
arch1.myattack(orc1);
if(orc1.get_life() <= 0){
cout<<orc1.get_name()
<<" **Died**";
break;
}
}
return 0;
}
@de_coder