473,383 Members | 1,877 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Compiler Error - Seeking help

When using the following code, I get the error "The type
"ConsoleApplication1.robot" already contains a definition for
'color"". I also get the error for "height".

If anyone could point me to the answer to this issue or documentation
describing what I am doing incorrectly I would appreciate it.

Thanks,
Jason

****Code****

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class robot
{
/* Defining robot attributes */

private string color;
private double height;

/* sets robot color */

public string color
{
get {return this.color; }
set {this.color = value; }
}

/* sets robot height */

public double height
{
get {return this.height; }
set { this.height = value; }
}

/* Create Object
<param color =color of robot </param>
<param height =height of robot </param>
*/

public robot(String color, Double height)
{
this.color = color;
this.height = height;
}
/* calculates weight based on height */

public double weight()
{
return 5 * this.height;
}

/*overloads ToString */

public string ToString()
{
return string.Format("{0,-20},{1,-10},{2,-10F1}",
this.color, this.height, this.weight());
}
}
}

Mar 8 '07 #1
3 1088
the accessor, "color/get/set", and the member datum "color" have the same
name. Rename the member variable to something like "theColor", and have
accessor "color/get" return it. Similarly for your other problems....
"lumien" <ho*********@gmail.comwrote in message
news:11********************@s48g2000cws.googlegrou ps.com...
When using the following code, I get the error "The type
"ConsoleApplication1.robot" already contains a definition for
'color"". I also get the error for "height".

If anyone could point me to the answer to this issue or documentation
describing what I am doing incorrectly I would appreciate it.

Thanks,
Jason

****Code****

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class robot
{
/* Defining robot attributes */

private string color;
private double height;

/* sets robot color */

public string color
{
get {return this.color; }
set {this.color = value; }
}

/* sets robot height */

public double height
{
get {return this.height; }
set { this.height = value; }
}

/* Create Object
<param color =color of robot </param>
<param height =height of robot </param>
*/

public robot(String color, Double height)
{
this.color = color;
this.height = height;
}
/* calculates weight based on height */

public double weight()
{
return 5 * this.height;
}

/*overloads ToString */

public string ToString()
{
return string.Format("{0,-20},{1,-10},{2,-10F1}",
this.color, this.height, this.weight());
}
}
}

Mar 8 '07 #2
On Mar 8, 2:11 pm, "Fred Mellender"
<nospamPlease_fr...@frontiernet.netwrote:
the accessor, "color/get/set", and the member datum "color" have the same
name. Rename the member variable to something like "theColor", and have
accessor "color/get" return it. Similarly for your other problems....

"lumien" <hodge.ja...@gmail.comwrote in message

news:11********************@s48g2000cws.googlegrou ps.com...
When using the following code, I get the error "The type
"ConsoleApplication1.robot" already contains a definition for
'color"". I also get the error for "height".
If anyone could point me to the answer to this issue or documentation
describing what I am doing incorrectly I would appreciate it.
Thanks,
Jason
****Code****
using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class robot
{
/* Defining robot attributes */
private string color;
private double height;
/* sets robot color */
public string color
{
get {return this.color; }
set {this.color = value; }
}
/* sets robot height */
public double height
{
get {return this.height; }
set { this.height = value; }
}
/* Create Object
<param color =color of robot </param>
<param height =height of robot </param>
*/
public robot(String color, Double height)
{
this.color = color;
this.height = height;
}
/* calculates weight based on height */
public double weight()
{
return 5 * this.height;
}
/*overloads ToString */
public string ToString()
{
return string.Format("{0,-20},{1,-10},{2,-10F1}",
this.color, this.height, this.weight());
}
}
}- Hide quoted text -

- Show quoted text -

Thx, I will try that.

Mar 8 '07 #3
Fred Mellender <no****************@frontiernet.netwrote:
the accessor, "color/get/set", and the member datum "color" have the same
name. Rename the member variable to something like "theColor", and have
accessor "color/get" return it. Similarly for your other problems....
Preferrably, keep the name of the field as color, but name the property
Color, to fit in with .NET naming conventions.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: administrata | last post by:
I'm programming Car Salesman Program. It's been "3 days" learning python... But, i got problem Write a Car Salesman program where the user enters the base price of a car. The program should...
3
by: Mark Rockman | last post by:
------ Build started: Project: USDAver2, Configuration: Debug .NET ------ Preparing resources... Updating references... Performing main compilation... error CS0583: Internal Compiler Error...
17
by: Student | last post by:
Hi All, I have an assignment for my Programming language project to create a compiler that takes a C++ file as input and translate it into the C file. Here I have to take care of inheritance and...
1
by: lumien | last post by:
When using the following code, I get the error "The type "ConsoleApplication1.robot" already contains a definition for 'color"". I also get the error for "height". If anyone could point me to...
1
by: kvarada | last post by:
Hello Experts, I am building my application on WinNT.4.0_i386_MSVC.7.1 platform. When I build the application on a stand alone machine, it builds fine. But when I build the same application from a...
41
by: Miroslaw Makowiecki | last post by:
Where can I download Comeau compiler as a trial version? Thanks in advice.
27
by: Dave | last post by:
I'm having a hard time tying to build gcc 4.3.1 on Solaris using the GNU compilers. I then decided to try to use Sun's compiler. The Sun Studio 12 compiler reports the following code, which is in...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.