Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #7898
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!news-1.dfn.de!news.dfn.de!news.informatik.hu-berlin.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Robert Klemme <shortcutter@googlemail.com> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: StatsTable object |
| Date | Mon, 12 Sep 2011 18:53:27 +0200 |
| Lines | 79 |
| Message-ID | <9d6roaFb8U2@mid.individual.net> (permalink) |
| References | <9ac3f834-0633-434c-86b0-49ed543f3e81@z18g2000yqb.googlegroups.com> <j4l32o$v4v$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net J1Hdd21zRgILj8CRkB3XMQ68vUNC0dWOVflsXamAEg1eIizGI= |
| Cancel-Lock | sha1:tocSzXRLSbTrVk7sNVow9ybNDHI= |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; WOW64; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 |
| In-Reply-To | <j4l32o$v4v$1@dont-email.me> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:7898 |
Show key headers only | View raw
On 12.09.2011 16:00, Jeff Higgins wrote:
> On 09/12/2011 04:23 AM, bob wrote:
>> I'm creating an object that represents a table of sports stats with
>> the player name as the first column and stat name as first row.
>> Here's an example:
>>
>> Touchdowns Yards Rushing Yards Passing
>> Dan Marino 2 200 55
>> Chad Henne 8 700 53
>> Brett Favre 7 300 44
>> Emmitt Smith 4 400 108
>>
>> What's the best way to represent this object in Java?
>>
>> I'm thinking of this:
>>
>> class StatsTable {
>> vector<String> strings;
>> int numColumns;
>> int numRows;
>> }
>>
>> What do you all think of this representation? I think it would be
>> better if it had a more 2-dimensional feel, but I don't want to
>> complicate things.
>
> import java.util.Vector;
>
> public class Scratch {
>
> public static void main(String[] args) {
> StatsTable stats = new StatsTable();
> stats.numColumns = 4;
> stats.numRows = 5;
> stats.strings = new Vector<String>();
> stats.strings.add("Player");
> stats.strings.add("Touchdowns");
> stats.strings.add("Yards Rushing");
> stats.strings.add("Yards Passing");
> stats.strings.add("Dan Marino");
> stats.strings.add("Chad Henne");
> stats.strings.add("Brett Favre");
> stats.strings.add("Emmitt Smith");
> stats.strings.add("2");
> stats.strings.add("8");
> stats.strings.add("7");
> stats.strings.add("4");
> stats.strings.add("200");
> stats.strings.add("700");
> stats.strings.add("300");
> stats.strings.add("400");
> stats.strings.add("55");
> stats.strings.add("53");
> stats.strings.add("44");
> stats.strings.add("108");
> }
>
> static class StatsTable {
> Vector<String> strings;
> int numColumns;
> int numRows;
> }
>
> }
>
>
Note that you can also do:
List<String> names = Arrays.asList("Player", "Touchdowns" ,...);
Kind regards
robert
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
StatsTable object bob <bob@coolgroups.com> - 2011-09-12 01:23 -0700
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 10:00 -0400
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 18:53 +0200
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 13:09 -0400
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 13:23 -0400
Re: StatsTable object markspace <-@.> - 2011-09-12 09:03 -0700
Re: StatsTable object Jeff Higgins <jeff@invalid.invalid> - 2011-09-12 12:59 -0400
Re: StatsTable object markspace <-@.> - 2011-09-12 09:58 -0700
Re: StatsTable object Lew <lewbloch@gmail.com> - 2011-09-12 15:30 -0700
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 18:52 +0200
Re: StatsTable object Knute Johnson <nospam@knutejohnson.com> - 2011-09-12 10:17 -0700
Re: StatsTable object Robert Klemme <shortcutter@googlemail.com> - 2011-09-12 19:19 +0200
Re: StatsTable object Arne Vajhøj <arne@vajhoej.dk> - 2011-09-12 19:28 -0400
Re: StatsTable object Arne Vajhøj <arne@vajhoej.dk> - 2011-09-12 19:30 -0400
csiph-web