Comp Sci NEED immediate help with enumerated data types JAVA

  • Thread starter Thread starter kirkulator
  • Start date Start date
  • Tags Tags
    Data Java
AI Thread Summary
The user is experiencing issues with implementing an enumerated data type in their Java program, specifically when trying to assign a paint color to a `UsedCars` object. They have defined an enum called `PaintColor` with various colors but are unable to use it correctly in their object creation. The user has attempted to input values like `RED` but encounters problems without specifying the exact error. Additional context about the code and error messages would help diagnose the issue more effectively. The user is new to Java programming and seeks guidance on using enumerated types.
kirkulator
Messages
32
Reaction score
0
okay so i have my program basically done, i just have one problem and it has to do with an enumerate data type i created

public enum PaintColor {RED, BLACK, WHITE, BLUE, GREEN, OTHER};

in my class that is UsedCars
im tracking attributes of these objects [used cars]
now...on my TestUsedCars class, I am trying to create the object

but no matter what i type in for paint color it doesn't work:

UsedCars basicCar = new UsedCars("honda", "9d9d9d9d0", 1999, 120000, x , 99.0);

'x' is the paintcolor
by the way, the other values are data fields:
carmake, vin number, year manufactured, odometer mileage, paintcolor, car condition rating

i tried putting in RED like i should be able to...or so i thought but it won't work.

thanks so much guys, i literally know nothing about using enumerated types. they just instructed me to do so and gave me one line of code on how to define the enum...so I am struggling figuring out how to do other things with it.

amanda
edit: by the way its beginning JAVA programming, sorry i didnt specify.
 
Physics news on Phys.org
kirkulator said:
okay so i have my program basically done, i just have one problem and it has to do with an enumerate data type i created

public enum PaintColor {RED, BLACK, WHITE, BLUE, GREEN, OTHER};

in my class that is UsedCars
im tracking attributes of these objects [used cars]
now...on my TestUsedCars class, I am trying to create the object

but no matter what i type in for paint color it doesn't work:

UsedCars basicCar = new UsedCars("honda", "9d9d9d9d0", 1999, 120000, x , 99.0);

'x' is the paintcolor
You should be able to put in RED or BLACK or other value of your enumerated type. When you say "it doesn't work," it would be helpful for you to tell us why it doesn't work. Also, without seeing your code, it's hard to understand what the difficulty is.

Seeing your code would help, as would the text of any compiler error that is generated.
kirkulator said:
by the way, the other values are data fields:
carmake, vin number, year manufactured, odometer mileage, paintcolor, car condition rating

i tried putting in RED like i should be able to...or so i thought but it won't work.

thanks so much guys, i literally know nothing about using enumerated types. they just instructed me to do so and gave me one line of code on how to define the enum...so I am struggling figuring out how to do other things with it.

amanda
edit: by the way its beginning JAVA programming, sorry i didnt specify.
 

Similar threads

Replies
12
Views
2K
Replies
2
Views
4K
Replies
7
Views
3K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Back
Top