473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Question regarding linking and moving - any advice greatly appreciated

Hey Everyone,

Thanks for reading, heres what I'm trying to do I have an array of say 10
items each item contains the text / description for a room.

Now I would like to create a class (lets call it BookSection) this class
will display the text for the current room the user is in and then have
links to other rooms (left, right, east, west, etc) then dependant upon the
choice made by the user will move to the new room and display the text

I've come up with the following code and after searching the books I have
(Head First Java, Just Java 2 and How to Program Java) and checking online
I'm at a loss and was wondering if anyone had any idea how to code this
(based on the bad and very limited code I have below)

class booksection{
int index //page number
string text //the story
int[]choices // the pages links
}

to display a page the program would display the string and the choices
and then load the choice the user made

method getchoices(page, thispage){
string text = "choises are"
thispage.choices.length
for (int i=0; i<2, i++){
text = text+thispage.choice[i]
}

return text
}

this would display the story and the appropriate choices

Any replies are greatly appreciated.
Nov 10 '05 #1
1 2707
Hey everyone,

someone I know gave me some advice but I'm not entirely sure what to do...

---------------

You should have a booksection class. This class can only contain methods and
variables related to a booksection so,

a booksection can have an int ID, String text, ArrayList or array of
choices: int[] choice;
and the methods it can implement are for example:(although there may be
more)

public String getText(){
return text;
}

public String getchoices(){ <----- see the difference between
this and yours. No parameters
String response = "choices are";
for (int i=0; i<choices.length, i++){
response = response+choice[i]
}

So each booksection can now output its text and choices.
In the main section not the booksection class we can (assuming we have
created a booksection object called myBookSection) get the choices for a
specific booksection by using for example:

String choices= myBookSection.getchoices();

The important point here is that each booksection object can now return the
text and choices that it contains. In the main java file, you have to find
the right booksection id from your ArrayList and then use its methods.

In the main program you should create around 10 booksection objects (read
from file or hard coded) and add these to an ArrayList of type
<booksection>.

The functionality for operating the book and turning to different
booksections should be implemented in the main java file.

If the user selects page 10 for example, you should find the booksection
with id 10 from your ArrayList of booksections and display the text and the
links for this page. This is then a recursive process.

Pseudo code for navigating the book:

create an empty booksection object
get the first page from your book arraylist and assign it to the booksection
object created above

While (number of links in booksection is not equal to 0)

{
Display the booksection id
Display the booksection text
Get the user to input the id of the next booksection -(use getchoice
method)
Get the user selected page from your book arraylist and assign it to the
booksection object created above
}

-----------------
"Kirok" <Na**@domain.com> wrote in message
news:Wk*****************@fe2.news.blueyonder.co.uk ...
Hey Everyone,

Thanks for reading, heres what I'm trying to do I have an array of say 10
items each item contains the text / description for a room.

Now I would like to create a class (lets call it BookSection) this class
will display the text for the current room the user is in and then have
links to other rooms (left, right, east, west, etc) then dependant upon
the choice made by the user will move to the new room and display the text

I've come up with the following code and after searching the books I have
(Head First Java, Just Java 2 and How to Program Java) and checking online
I'm at a loss and was wondering if anyone had any idea how to code this
(based on the bad and very limited code I have below)

class booksection{
int index //page number
string text //the story
int[]choices // the pages links
}

to display a page the program would display the string and the choices
and then load the choice the user made

method getchoices(page, thispage){
string text = "choises are"
thispage.choices.length
for (int i=0; i<2, i++){
text = text+thispage.choice[i]
}

return text
}

this would display the story and the appropriate choices

Any replies are greatly appreciated.

Nov 10 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mason | last post by:
This is probably an incredibly newbie-ish question. I just haven't had the cause to use many subforms before, so I'm pretty sure I just don't understand it correctly (even after reading up on it)....
4
by: carpenti | last post by:
Dear all, I am learning C++ and I got a little confused about dynamic allocation of arrays. Any help is greatly appreciated. In the following piece of code, is the use of the operator new...
2
by: et | last post by:
I am new to asp.net. I am writing a program that will revolve around an extensive client database, and wonder what the best way to design the program is, using classes. I have about 10 different...
3
by: Charles Nicholson | last post by:
Hello all- I have some static C++ libraries that I wrote in VS2003 but which upgraded fine when i went to VS2005 Pro. In them i overload the global versions of operators new, new, delete, and...
5
by: Keith | last post by:
Hello all, I have a C# Windows Forms app. It is in namespace App.GUI. It builds to Nav.exe. I have entered an application level setting using the designer. Its type is string, name is "FOO"...
3
by: provowallis | last post by:
I'm new to this board so I hope this reqest isn't out of line, but I'm looking for some general advice about creating links in online books. If the link target didn't involve PIs I don't think I'd...
12
by: nyathancha | last post by:
Hi, I have a question regarding best practices in database design. In a relational database, is it wise/necessary to sometimes create tables that are not related to other tables through a...
10
by: somenath | last post by:
Hi All, I have one question regarding return value cast of malloc. I learned that we should not cast the return value of malloc because it is bug hider. But my question is as mentioned...
2
by: runway27 | last post by:
i am helping a friend to build a forum website which uses php and mysql database. i am working on the registeration page for the forum website and its validation. i am using php 5.2.5 i am able to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.