From: Jed Kowalski Date: 2008-06-10T03:40:59+09:00 Subject: C++ 2 Ruby Greetings Ruby fans :) From a couple of months I've been learning C++ but after I found out about Ruby... it's just GREAT! Right now im at a beginner level, trying to convert some simplier code to Ruby (it's easier for me to learn this way) Can somebody please help me a little? ;> Ofcourse a working example would be also nice ;) BTW sorry for my English... //--------------------------------------------------------------------------- #include //WHAT TO DO WITH THOSE #include #include //--------------------------------------------------------------------------- #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;}; int buy(){return bought;}; bool canbuy(){ if (amount==0) return false; else return true; }; void namea(){cout<0; j--) { if ((x-tab[1][i])> -0.0001) { tab[0][i]--; x=x-tab[1][i]; cout<>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<<": "<>g; if (Drinke[g].canbuy()) { y=1; s=0; while (y!=0){ cout<<"Coins Input: "<>y; if (y==0) { cout<<"Input Coins. "; cin>>m; s+=m; p.add(m); } if ((y==1)&&(Drinke[g].change(s)<0)) {cout<<"No cash. Input Coins."<