• Post Reply Bookmark Topic Watch Topic
  • New Topic

toString() method for FORMULA class  RSS feed

 
amitesh kumar
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

In my current project there is a class defined as:
public class APPLIEDRATES {
....
...

public static final class FORMULA extends LinkedHashMap<LHSRATE, HashMap<String,RHSRATE>> {
private static final long serialVersionUID = -4754565974505570612L;
private FORMULA () {super(10);}
}
--
--
public static final class LHSRATE{}
public static final class RHSRATE{}
}

Please help me write toString() method for FORMULA class.

Please note that LHSRATE and RHSRATE hv toString() methods defined.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

Hmmmmm. Well, toString() is generally used to provide a simple, readable snapshot of an object's state, handy for debugging or informal reporting.

Since we don't know anything at all about what any of these classes are or what they do, I'm finding it hard to imagine why you'd think we could be much help here.

So what would you like to see displayed if someone prints a FORMULA object?
 
amitesh kumar
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the reply.

as per my TL's suggestion first i've to call toString method of LHSRATE for each of the key values of FORMULA object then using a nested loop print values of RHSRATE.

something like

public String toString() {
StringBuffer sb = new StringBuffer("=========== Formula==============\n");

//define some iterator of FORMULA type
//loop all key for FORMULA
// call toStrind() method of LHSRATE
//append these to sb;
//loop all values for FORMULA
//loop keys of String name for RHSRATE
//append these to sb;
//call toStrind() method of RHSRATE
//append these to sb;
// ..

....




}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so what part are you having trouble with?
 
amitesh kumar
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've the rough idea abt the code. i'm not able to write the correct code. please help me i've hardly writtensome codes in core java collections api and this one requires Generics knowledge
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you need to hire a programmer. We're got a "Jobs Offered" forum on this site you could use.

Alternatively, here is some useful documentation; note the link to Sun's generics tutorial at the bottom of the page. You've got some reading to do!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!