```Greetings Ruby fans :)
From a couple of months I've been learning C++ but after I found out
Right now im at a beginner level, trying to convert some simplier code
to Ruby (it's easier for me to learn this way)
Ofcourse a working example would be also nice ;)

BTW sorry for my English...

//---------------------------------------------------------------------------
#include<math.h> //WHAT TO DO WITH THOSE
#include<iostream>
#include<cstdio>

//---------------------------------------------------------------------------
#pragma argsused
using namespace std;
class Drink{
double price;
char name[20];
int amount,bought;
public:
Drink(double cen, int how_much, char* nn) {
price=cen;
amount=how_much;
strcpy(name,nn);
bought=0;
};
double change(double x){
amount--; //HOW TO DO THIS
bought++;
return x-price;
};
int amounti() {return amount;};
double pricea(){return price;};
if (amount==0)
return false;
else return true;
};
void namea(){cout<<name;};
friend class Automat; //WHAT TO DO WIGHT THIS
};
class Automat{
private:
double tab[2][8],u,w,x;
public:
Automat(double pie,double dwa,double jed,double piec,double
{
tab[0][0]=pie;
tab[0][1]=dwa;
tab[0][2]=jed;
tab[0][3]=piec;
tab[0][5]=dzi;
tab[1][0]=5;
tab[1][1]=2;
tab[1][2]=1;
tab[1][3]=0.5;
tab[1][4]=0.2;
tab[1][5]=0.1;
};
void Coinsy(Drink *n,double s,int g){
x=s-n[g].price;
for (int i = 0; i <=5; i++) {
w=tab[0][i];
for (double j =w; j>0; j--)    {
if ((x-tab[1][i])> -0.0001)    {
tab[0][i]--;
x=x-tab[1][i];
cout<<tab[1][i]<<endl;
}
}
}
};
void write(){
cout<<"Coins 5zl: "<<tab[0][0]<<endl;
cout<<"Coins 2zl: "<<tab[0][1]<<endl;
cout<<"Coins 1zl: "<<tab[0][2]<<endl;
cout<<"Coins 50gr: "<<tab[0][3]<<endl;
cout<<"Coins 20gr: "<<tab[0][4]<<endl;
cout<<"Coins 10gr: "<<tab[0][5]<<endl;
};
if  (x==5) tab[0][0]++;
if  (x==2) tab[0][1]++;
if  (x==1) tab[0][2]++;
if  (x==0.5)tab[0][3]++;
if  (x==0.2)tab[0][4]++;
if  (x==0.1)tab[0][5]++;
}
};

int main()
{
int q=1,y,i,g;
double m=1,s=0;
Automat p(15,15,20,25,25,25);
Drink Drinke[3]= {
Drink(1.7,0,"Coca-Cola"),
Drink(2,0,"Sprite"),
Drink(2.1,20,"Fanta")
};

while(q!=0)
{
cout<<"What would you like to do?"<<endl;
cout<<"Kupic Drink: press 1"<<endl;
cout<<"Print Coins report: press 2"<<endl;
cout<<"Print bought Drinks report: press 3"<<endl;
cout<<"Exit: press 0"<<endl;
cin>>q;
switch (q) //I'M NOT QUITE SURE HOW TO USE SWITCH IN RUBY
{
case 1: {
system("cls");
for (int j = 0; j <3; j++) {
Drinke[j].namea();
cout<<": "<<Drinke[j].pricea()<<" nacisnij "<<j<<endl;
}
cin>>g;
y=1;
s=0;
while (y!=0){
cout<<"Coins Input: "<<s<<endl<<" What to do: \n\t\t
Input Coins: 0 \n\t\t Buy Drink: 1 \n\t\t Cancel: 2"<<endl;
cin>>y;
if (y==0) {
cout<<"Input Coins. ";
cin>>m;
s+=m;
}
if ((y==1)&&(Drinke[g].change(s)<0))  {cout<<"No cash. Input
Coins."<<endl;}
else {
cout<<"change: "<<endl;
p.Coinsy(Drinke,s,g);
}
if (y==2) { break; }
}
}
else cout<<"No such drink."<<endl;
}
case 2:
p.write();
case 3: {
system("cls"); //CAN YOU CLEAR SCREEN IN RUBY?
cout<<"Drinks bought: "<<endl;
for (int i=0; i <3; i++)  {
Drinke[i].namea();
}
cout<<endl;
break;
}
}
}
getchar(); getchar();
return 0;
}
//---------------------------------------------------------------------------
--
Posted via http://www.ruby-forum.com/.

```