Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,547 members, 7,809,009 topics. Date: Thursday, 25 April 2024 at 09:04 PM

C++ To Java - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / C++ To Java (992 Views)

Access To Java Overview Platform / To Java Certify Or Not? / Why Do .net Programmers Prefer C# To Vb In Developing Web Application (2) (3) (4)

(1) (Reply) (Go Down)

C++ To Java by uenemuoh(m): 10:43am On May 09, 2008
pls can any java guru please help me transform this c++ source code to java.wud 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"wink,Name("X"wink {
}

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;
}
Re: C++ To Java by javadevil: 12:33pm On May 13, 2008
i'll really love to help if you can tell me exactly what you want to do cos your code is not clear. one very important thing in programming is code clarity
Re: C++ To Java by Bassie(m): 1:09pm On May 13, 2008
What's the code supposed to do!That's key to finding Help!
Re: C++ To Java by c0dec(m): 9:03pm On May 13, 2008
uenemuoh:

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"wink,Name("X"wink {
}

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.

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.

(1) (Reply)

Help Wit Java Programming / How Dyu Play Mp3 files In Java? / Reactivation My Nairaland

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.