473,787 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.choice s.length
for (int i=0; i<2, i++){
text = text+thispage.c hoice[i]
}

return text
}

this would display the story and the appropriate choices

Any replies are greatly appreciated.
Nov 10 '05 #1
1 2741
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:(althou gh 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.lengt h, 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.g etchoices();

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.co m> wrote in message
news:Wk******** *********@fe2.n ews.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.choice s.length
for (int i=0; i<2, i++){
text = text+thispage.c hoice[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
2316
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). I have a relationship set up that is used to track the hours an employee has worked on each project during the week. I'm trying to set up a Form to allow someone to choose their name and a Period Ending date (basically, the tblTimeReport...
4
1621
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 strictly necessary ? I mean, can I safely replace the line "a=new double;" with "double a", and keep "delete a;" to free the reserved memory ? Many thanks in advance.
2
1236
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 sections, or categories if you will, about a client. For instance, some clients have data regarding our Estate Planning section, some clients have data regarding our Real Estate section, etc. Would it be better to have one object that...
3
5120
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 delete. I also use the STL and parts of boost (shared_ptr<> and weak_ptr<>) pretty heavily. They have dependencies on various windows libs (dbghelp, winsock, etc...). These static libraries have no common runtime support at all and use the...
5
5736
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" and value is "monkey". I've tried the following ways to retrieve the value and only one works: //Returns null Configuration config = ConfigurationManager.OpenExeConfiguration(Assembly.GetEntryAssembly().Location); string monkey =...
3
1597
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 be here, but since it does, I'd be interested in getting some different perspectives on this. I have an XML book and I plan to create XHTML so I'm looking for the best way to create links from the various components of the book to the page...
12
7021
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 foreign Key relationship or does this always indicate some sort of underlying design flaw. Something that requires a re evaluation of the problem domain? The reason I ask is because in our application, the user can perform x
10
1912
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 bellow . Lets say I have not included stdlib.h in my program still I am using malloc so compiler will throw warring because with out prototype
2
1823
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 validate and do other tasks, however i really need help as i am stuck with regards to database injection. please answer the following questions. any help will be greatly appreciated. 1. USER NAME VALIDATION username = eregi("^+$",...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10169
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.