Solved

Java typesafe file parser

Posted on 2010-08-23
7
308 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

752 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