Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #22281

Re: Converting Text File To Rectangles

From Arved Sandstrom <asandstrom2@eastlink.ca>
Newsgroups comp.lang.java.programmer
Subject Re: Converting Text File To Rectangles
References <7f49c487-f016-43a3-83a4-feebe072f76c@googlegroups.com>
Message-ID <hknSs.136174$EO2.136144@newsfe04.iad> (permalink)
Organization Public Usenet Newsgroup Access
Date 2013-02-12 04:47 -0400

Show all headers | View raw


On 02/11/2013 09:51 PM, Scyth3 wrote:
> I have a save and load method for certain rectangles I need for a game. Say the user wants to save a map. The outputted map would look like this:
>
>
> 50 250 50 50
> 50 350 50 50
> 50 400 50 50
> 50 500 50 50
> 150 300 50 50
> 200 450 50 50
> 200 500 50 50
> 250 150 50 50
> 300 100 50 50
> 400 50 50 50
> 450 150 50 50
> 550 100 50 50
>
> X Y Width Height
>
> Now, how would I read this, and turn it into a rectangle?
>
You _already_ have a "save and load" method, or you'd _like to_ have all 
of the above? This is basic enough to practically be a CS assignment; 
even if not, it's not doing you any learning favours to tell you much 
about how to do any of this.

Think the problem though, and decompose it. You have that file, and 
assume it's been created by a save method operating on a list of 
rectangle objects. Now you need to read it - find the Java packages and 
classes that have to do with reading from text files. Determine how to 
read line by line from such a file. Either operate on each line as you 
read it, or store the lines to do that as a second step. Decide how 
you'll split each line into 4 text representations of numbers, and how 
you'll convert each into a number.

Do you even have a rectangle class ready to go?

AHS

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Converting Text File To Rectangles Scyth3 <zfollette@gmail.com> - 2013-02-11 17:51 -0800
  Re: Converting Text File To Rectangles Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-11 21:02 -0500
    Re: Converting Text File To Rectangles Gene Wirchenko <genew@telus.net> - 2013-02-13 09:06 -0800
      Re: Converting Text File To Rectangles Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-13 13:25 -0500
        Re: Converting Text File To Rectangles "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-02-15 15:25 +0000
          Re: Converting Text File To Rectangles "John B. Matthews" <nospam@nospam.invalid> - 2013-02-16 13:37 -0500
            [OT] Re: Converting Text File To Rectangles Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-02-16 15:16 -0500
              Re: [OT] Re: Converting Text File To Rectangles "John B. Matthews" <nospam@nospam.invalid> - 2013-02-17 14:16 -0500
        Re: Converting Text File To Rectangles Gene Wirchenko <genew@telus.net> - 2013-02-15 13:09 -0800
  Re: Converting Text File To Rectangles Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-02-12 04:47 -0400
    Re: Converting Text File To Rectangles lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-12 12:14 +0000
  Re: Converting Text File To Rectangles lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-12 09:47 +0000
    Re: Converting Text File To Rectangles lipska the kat <"nospam at neversurrender dot co dot uk"> - 2013-02-12 09:50 +0000
    Re: Converting Text File To Rectangles Roedy Green <see_website@mindprod.com.invalid> - 2013-02-12 18:23 -0800
  Re: Converting Text File To Rectangles Roedy Green <see_website@mindprod.com.invalid> - 2013-02-12 11:41 -0800

csiph-web