• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 312
  • Last Modified:

Java typesafe file parser

I have a input file contains Color, Size and Shape like this:
RED LARGE TRIANGLE YELLOW SMALL SQUARE ...

Color would be RED YELLOW BLUE
Size would be LAREG SMALL MEDIUM
Shape would be TRIANGE CICLE SQUARE
All the three classes implements the same interface.

I need three bean classes which are Color, Size and Shape and driver class to read this file and loaded into each bean class and sort them, search them. Also I need make sure typesafe is used to make sure what is read is right. So Enum should be used for the bean classes.

0
SarahDeng
Asked:
SarahDeng
3 Solutions
 
SarahDengAuthor Commented:
I should give more details about this. Except those three bean classes, Color, Size and Shape which implements the same interface,
I have another bean class which has those three bean classes as property. e.g.
class MyClass{
      Color color;
      Size size;
      Shape shape;

}
And the driver class will read the file and load the input to MyClass, then sort MyClass.
0
 
ManishLeadCommented:
0
 
SarahDengAuthor Commented:
I know how to read the file and parse them into those bean class, but I got stuck at how to use Color, Size, and Shape as Enum. which is typesafe.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
SarahDengAuthor Commented:
Let me add more detail. The Color class would be like this
class Color{

    String color; //The color should be one of them, like RED BLUE YELLOW

    public String getColor(){
    return color;
    }
   public void setColor(String color){
   this.color = color;
   }
 }

The same thing for Size and Shape class.
0
 
objectsCommented:
0
 
SarahDengAuthor Commented:
Thanks!!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now