Solved

Java typesafe file parser

Posted on 2010-08-23
7
303 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
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
scoresSpecial  challenge 13 40
array220 challenge 8 46
json format text only 4 65
wordcount challenge 11 76
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now