C++ To Java

A Member? Please Login  
type your username and password to login
Date: May 16, 2008, 06:20 PM
201236 members and 113393 Topics
Latest Member: kingston05
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  C++ To Java
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: C++ To Java  (Read 61 views)
uenemuoh (m)
C++ To Java
« on: May 09, 2008, 10:43 AM »

please can any java guru please help me transform this c++ source code to java.would awfully appreciate this help from anyone.

class Article {
   private:
      float PricePerPiece;
      string StripCode,Name;
   public:
      Article();
      Article(float,string,string);
      ~Article() {
    cout << "Message from the \"Article\" - destroyed!" <<
       endl;
      }
      float GetPricePerPiece() const {
         return PricePerPiece;
      }
      void SetPricePerPiece(float X) {
         this->PricePerPiece = X;
      }
      string GetStripCode() const{
      return StripCode;
      }
      void SetStripCode(const string& StripCode){
      this->StripCode= StripCode;
      }

      string GetName()const{
       return Name;

      }

      void setName(const string& X) {
      this->Name=X;
      }
      void Print() const;
};

Article::Article() : PricePerPiece(1), StripCode("A"),Name("X") {
}

Article::Article(float PricePerPiece,string StripCode,string Name)  {
this->PricePerPiece = PricePerPiece;
this->StripCode= StripCode;
this->Name=Name;
}

inline void Article::Print() const {
   cout << "Price Per Piece = " << PricePerPiece << ", Strip Code = " << StripCode <<"Name = "<<Name;
}
javadevil
Re: C++ To Java
« #1 on: May 13, 2008, 12:33 PM »

i'll really love to help if you can tell me exactly what you want to do because your code is not clear. one very important thing in programming is code clarity
Bassie (m)
Re: C++ To Java
« #2 on: May 13, 2008, 01:09 PM »

What's the code supposed to do!That's key to finding Help!
c0dec (m)
Re: C++ To Java
« #3 on: May 13, 2008, 09:03 PM »

Quote from: uenemuoh on May 09, 2008, 10:43 AM
please can any java guru please help me transform this c++ source code to java.would awfully appreciate this help from anyone.

class Article {
   private:
      float PricePerPiece;
      string StripCode,Name;
   public:
      Article();
      Article(float,string,string);
      ~Article() {
    cout << "Message from the \"Article\" - destroyed!" <<
       endl;
      }
      float GetPricePerPiece() const {
         return PricePerPiece;
      }
      void SetPricePerPiece(float X) {
         this->PricePerPiece = X;
      }
      string GetStripCode() const{
      return StripCode;
      }
      void SetStripCode(const string& StripCode){
      this->StripCode= StripCode;
      }

      string GetName()const{
       return Name;

      }

      void setName(const string& X) {
      this->Name=X;
      }
      void Print() const;
};

Article::Article() : PricePerPiece(1), StripCode("A"),Name("X") {
}

Article::Article(float PricePerPiece,string StripCode,string Name)  {
this->PricePerPiece = PricePerPiece;
this->StripCode= StripCode;
this->Name=Name;
}

inline void Article::Print() const {
   cout << "Price Per Piece = " << PricePerPiece << ", Strip Code = " << StripCode <<"Name = "<<Name;
}


Just because I'm bored this moment and have nothing better in my life to do.

Code:
public class Article
{
private float PricePerPiece;
private String StripCOde;
private String Name;

public Article()
{
PricePerPiece = 1;
StripCode = "A";
Name = "X";
}


public Article(float pricePerPiece,string stripCode, string name)
{
PricePerPiece = pricePerPiece;
StripCode = stripCode;
Name = name;
}


public float GetPricePerPiece()
{
return PricePerPiece;
}

public void SetPricePerPiece (float X)
{
PricePerPiece = X;
}

        public String GetStripCode()
{
return StripCode;
}

      public void SetStripCode(String X)
{
      StripCode = X;
      }

public String GetName()
{
return Name;
}

public void setName(String X)
{
Name = X;
}

public void Print ()
{
System.out.println("Price per Piece = " + PricePerPiece + ", Strip Code = " + StripCode + ", Name = " + Name);
}
}

I have a feeling it's not 100% correct. I'll leave that to you to figure out. I'm in no way a Java guru. I'm well below average with Java. I'm just quite good with C/C++ and this is pretty easy stuff.
 If You Can Dream It, We Can Develop It And Make It Happen For You  It And Non-it Certificatin Training At Octi  Getting The Services Of An Advertising Agency  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Jobs (2) Career Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Powered by: SMF, © 2001-2005, Lewis Media. All Rights Reserved.