Solved

Java typesafe file parser

Posted on 2010-08-23
7
307 Views
Last Modified: 2012-05-10
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
Comment
Question by:SarahDeng
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:SarahDeng
ID: 33507856
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
 
LVL 11

Assisted Solution

by:Manish
Manish earned 100 total points
ID: 33507861
0
 

Author Comment

by:SarahDeng
ID: 33507937
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:SarahDeng
ID: 33507958
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
 
LVL 92

Accepted Solution

by:
objects earned 300 total points
ID: 33507974
0
 
LVL 16

Assisted Solution

by:Valeri
Valeri earned 100 total points
ID: 33521017
0
 

Author Closing Comment

by:SarahDeng
ID: 33536063
Thanks!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question