Making a highscores table
Hii - im a beginner at java, and i've been trying to make a highscores table for my game (who wants to be a millionaire)
it compiles perfectly and runs, but everytime i enter the method at the end of the program, it crashes
can someone look at my method and try to find the problem? thanks so much =(
public static String [] highscores (String [] name, int amount2, int m) throws IOException
String [] highscores = new String [100];
int [] scores = new int [100];
int i, j, t = 0;
String temp = "asdf";
String [] Stringscores = new String [100];
readScores(Stringscores); // reads file that i save my scores into
readNames(name); // reads file that i save my names into
for (int a = 0; a < Stringscores.length; a++)
scores[a] = Integer.valueOf(Stringscores[a]).intValue();
scores[m] = amount2; // m is the number of times the player plays the game (first time they play, m = 0, second time they play, m = 1, etc)
Stringscores[m] = Integer.toString(scores[m]);
for(i = 0; i < scores.length; i++)
for(j = 1; j < (scores.length - i); j++)
if(scores[j-1] < scores[j])
t = scores[j-1];
scores[j-1] = scores[j];
scores[j] = t;
temp = name[j-1];
name[j-1] = name[j];
name[j] = temp;
for (int a = 0; a < scores.length; a++)
Stringscores[a] = Integer.toString(scores[a]);
saveScores(Stringscores); // saves elements of array to file
saveNames(name);
for (int a = 0; a < Stringscores.length; a++)
scores[a] = Integer.valueOf(Stringscores[a]).intValue();
for (int k = 0; k < scores.length; k++)
if (name[k] != null)
System.out.println(name[k]);
System.out.println(scores[k]);
return highscores;
}
and my advice for you: post something that actually answers people's questions.He brought you much much closer to getting a useful answer that people trying random advice based on tedious code-reading in an unfitting font and layout.
But you're free to choose to ignore the advice, you probably know better...
it compiles perfectly and runs, but everytime i enter the method at the end of the program, it crashesWhat do you call "crashing"? It core-dumps? It throws an Exception? It gives a wrong result? It loops forever?
Random try (based on my not reading the unformatted code): it throws an Exception. What is the Exception class and message, which line is it thrown at?
Edited by: jduprez on Jun 7, 2009 8:35 PM - removed dismissive comment on OP newbie status (warranted given the unbased gnawing at a helpful hand, but discouraging for other new users)
Similar Messages
-
Making data in tables online and offline - Backup/Recovery for tables.
Hi All,
I'm working on a project where the functionality is similar to 'Backup and Recovery' for database tables.
Lets say we have a set of 6 tables T1, T2.... T6. They do have relationship between them. The tables in questions are simple standard tables, which are not table partitioned.
- I want remove the records from live tables based on user entered date ranges and store it in some offline medium.
- I might want make the data online again from the offline medium; Application should be able use that data without any modifications.
- Different offline mediums can be
a) Flat file
b) Different table space
c) Any other secondary medium (like XML, tape..Etc,)
The total number of records will run in millions.
The proposed solution should consider,
1. Performance - Java solutions not feasible. Anything in SQL, PL/SQL or runs in DB itself(tools) are OK.
2. Reliability - Should be highly reliable, Data corruption simply unacceptable.
3. Security - Users should not be able to make out of the file.
Few options include:
1. Use partition
2. Use SQL*Loader
3. Export and import of tables.
My main targets:
1. Reduce space.
2. Increase performance for queries.
Please pass on your suggestions, any help is highly appreciated!
Thanks In Advance!If you truely need to get the data out of the Oracle database into flat files, partitioning is pretty useless. Partitioning the table, though, strikes me as by far the most efficient, reliable, and secure solution.
What sort of security do you need with the flat file? Do you need the data in the file to be encrypted, or is the binary file format of an Oracle export file sufficiently obfuscated?
I'd stay away from UTL_FILE here, just because performance is rather poor.
I always get pretty nervous about recoverability when people start moving data out of the database to flat files for long-term archival.
- If you ever change the data model, even slightly, you may not be able to move the data back into the database without modifying your loader. A few years down the line, after a few data model changes, it can be almost impossible to find the documentation to make that change.
- If you do things like change lookup tables over time, reloading data can cause major problems. When you load the data back in, your applications and reports may not treat the old codes properly.
- Making sure that the flat files get stored and tagged properly can be a challenge. When the database gets moved to new system, you have to make sure that all the flat files also get moved around and the the loader scripts are modified appropriately.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Making a text table flow from page to page?
I'm creating a template in InDesign that will be used to create tags, using a simple table and paragraph formatting to create heirarchy on each tag. I need to flow long lists of text from Word or Excel to the table, and since there are only 10 tags on each page, there will inevitably be multiple pages of tags.
Is there a way to create a table that spans multiple pages (preferably expandable) and allows text to flow into the multiple page tables?
The tags must be formatted a certain way, so there isn't any room for auto-styling unless the new pages follow exactly the styles of the existing pages.You have the data in an Excel file? Are these "tags" like some sort of product label? D they all look the same, except for the actual text?
If the answer to the above questions is "yes," openthe Help file and look up Data Merge. -
Making data in tables online and offline - Backup and Recovery
Hi All,
I'm working on a project where the functionality is similar to 'Backup and Recovery' for database tables.
Lets say we have a set of 6 tables T1, T2.... T6. They do have relationship between them. The tables in questions are simple standard tables, which are not table partitioned.
- I want remove the records from live tables based on user entered date ranges and store it in some offline medium.
- I might want make the data online again from the offline medium; Application should be able use that data without any modifications.
- Different offline mediums can be
a) Flat file
b) Different table space
c) Any other secondary medium (like XML, tape..Etc,)
The total number of records will run in millions.
The proposed solution should consider,
1. Performance - Java solutions not feasible. Anything in SQL, PL/SQL or runs in DB itself(tools) are OK.
2. Reliability - Should be highly reliable, Data corruption simply unacceptable.
3. Security - Users should not be able to make out of the file.
Few options include:
1. Use partition
2. Use SQL*Loader
3. Export and import of tables.
My main targets:
1. Reduce space.
2. Increase performance for queries.
Please pass on your suggestions, any help is highly appreciated!
Thanks In Advance!Few points to note:
1. I agree partition would be right solution, but as I mentioned in my earlier statement, 'The tables in questions are simple standard tables, which are not table partitioned.'. The tables right now are not partitioned and I believe we cannot add/modify partitions, if the table were not created with the partition option. One work around is to build a partitioned table and copying all the properties(indexes,rows,constraints) from the existing non-partitioned table. But I suspect this is highly riskier and we can't afford to it.
2. I need to support Oracle database versions starting from 8.0.6.
3. Flat file is mandatory, others are optional. I can restrict our discussion just for a file.
4. Considering the above points, the only option I could think of is I can move the records from the table to flat file and remove from tables. When required rollback the file data to the table and application would be able to use it. For export/import few options are: SQL*loader, exp/imp utilities, PL/SQL file UTL packages
Thanks In Advance -
Hi,
I have two file path at selection screen where I upload one field names file and one record file for the fields uploaded.
I have an internal table with fields id, pid, structure_name, pk_field(parent key), fk_field(foreign key),fields(table type-the file field names that uploaded in my selection screen),data(this is also a table and has the record file that I have uploaded at selection screen).My internal table looks as follows:
ID PID structure_name pk_field fk_field fields data
1 header abcd t_fields1 t_rec1
2 1 item gfh abcd t_fields2 t_rec2
Now my requirement is to flatten the data into single table with the following fields based on the parent key(pk) and foreign key(fk) relation.Can anyone suggest how to do it.
structure_name
field_name
pk
fk
value
Edited by: Ginger on Jul 27, 2009 1:53 AMOne more thing which I don't get. Does DYN_TABLE holds values 1,2,3 as 3 records?
1) value 1
2) value 2
3) value 3
or
this is just one record with different fields, but you only want to copy those F1, F2, F3 fields for which values are like 1, 2, 3, to new table?
I think you mean the second, so this would be what you need
data: it_fcat type lvc_f_cat with header line.
"first creat field catalog based on fields names
loop at fields.
it_fcat-fieldname = fields-name.
"give field type, either excplicitly or via DDIC reference
it_fcat-INTTYPE = ...
it_fcat-INTLEN = ...
append it_fcat.
endloop.
now create new dynamic table
field-symbols <new_tab> type any table.
data: new_table type ref to data.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = is_fcat
IMPORTING
ep_table = new_table.
assign new_table->* to <new_tab>.
Last thing you need is to move values from DYN_TAB to corresponding NEW_TAB
data: wa_dyn_tab type ref to data,
wa_new_tab type ref to data.
field-symbols <dyn_tab> type any table,
<wa_dyn> type any,
<wa_new> type any.
assign dyn_tab->* to <dyn_tab>.
"create work areas for both tables
create data: wa_dyn_tab like line of <tab>,
wa_new_tab like line of <new_tab>.
assign: wa_dyn_tab->* to <wa_dyn>,
wa_new_tab->* to <wa_new>.
"now copy content from DYN_TAB to NEW_TAB using <wa_dyn> and <wa_new>.
loop at <dyn_tab> into <wa_dyn>.
move-corresponding <wa_dyn> to <wa_new>.
append <wa_new> to <new_tab>. "now <new_tab> contains only corresponding values from <dyn_tab> based on FIELDS table
endloop.
Hope this is what you need
Regards
Marcin -
In WD application making one WD-table field un-editable.
Hi,
I have changed one WD application and I have added one table(Layout data: Matrix head data),
in which I made one column as editable"Bind to property of the selected attribute-Enabled". My requirement
is to make for one particular row - make that column non-editable.
Please let me know if anyone come across this kind of requirement?
I wrote a code in method for the element(table): WDDOMODIFYVIEW
* lo_el_nd_partner = lo_nd_nd_partner->get_element( index = sy-tabix ).
* lo_el_nd_partner->set_attribute_property(
* attribute_name = 'GPARN'
* property = 3 "Property 3 for read-only
* value = 'X'). "Disable vendor number editing for VN row
But still it is editable.
Best regards,
Anilkumar.Hi Anil,
As you are having a context attribute ZGPARN_READONLY to make the columne GPARN as read only based on the value inside the table.
You just need to bind the READONLY property of GPARN to context attribute ZGPARN_READONLY as below
Now, if you pass value X to attribute, then the particular cell will be made as read only
"Read table data from context node into lt_nd_parnter.
loop at lt_nd_partner assigning <ls_partner> where parvw = 'VN'.
<ls_partner>-ZGPARN_READONLY = abap_true.
endloop.
" bind the table to context node
lo_node->bind_table( new_items = lt_nd_partner ).
Hope this helps you.
Regards,
Rama -
Making Itemlistbox and table as mandatory
Hi All,
Do any one know how to make Item list box and table as mandatory fields?.I just want to have that " * " sign in front of those two
fields.
For input field i have changed the value of state to " Required". But i am not able to find any "state" property for Item list box and
table. Could any one help me out.
Thanks,SwarnaprakashHi
As this is not any input related UI , list box is intended for selectionn among available options ,this option will not be there , still if you want to show it then use one similar Image UI in front of this UI. and manually do the validation for selection / rejection .
Best Regards
Satish Kumar -
Hi,
I want to add some objects in TCLO table in order to make document links for O4V1,04G1 T-code in DMS (CV01n/2n/3n/4n).
I want to link Vehicles with DMS is it possible???
Thanx & Best Rgds,
Akhilhi Akhil,
Since table maintenance is allowed for TCLO, you can maintain the data from SM30. (if maintenance generator is not created, create it navigating from SE11->utilities->table maintenance generator)
Sajan. -
Making row of Table Maintanance uneditable
Hi All,
I am developing a Table Maintanance of a ZTable. The ZTable contains 13 fields. The user have to key in data into the ZTable through Table Maintanance. One of the field in the ZTable is "Approval". If the User marks "X" into the Approval field then the entire row in the Table Maintanance would become uneditable for a certain end user but would remain editable to higher Managers (Through SY-UNAME).
Pls suggest, how do I create the entire row uneditable for certain end user but the same row editable for the other higher Managers.
Appreciate if you can provide the code or provide some documents on that.
Regards,
Rubel.Hi,
Thanx Karthik.
Can you pls suggest what is the correct Authorization Object we can use for this senario. Can we use:-
Object : S_TABU_DIS
Text : Table Maintenance (via standard tools such as SM30)
Class : BC_A
If there are some more Authorization Object then pls refer the name.
OR, do we have to create a new Authorization Object? If Yes, then pls give the steps as to how can we create a new authorizaton object with new class.
Regards,
Rubel. -
Making row in table current?
in 11g I have to write my own selection listener for table but I wont that selected row become current - how to do that?
Hi,
if you use data binidings for the table, then the default selection listener is something like
#{bindings.something.collectionModel.makeCurrent}
This does exactly that, so in your selectionListener you can execute that with:
JSFUtils.executeAction("#{bindings.something.collectionModel.makeCurrent}");
{code}
If you don't have JSFUtils class search the forums, including TP forum, but the code is something like this:
{code:java}
JUCtrlActionBinding a = (JUCtrlActionBinding)resolveExpression("#{bindings." + actionName + "}");
a.execute();
public static Object resolveExpression(String expression) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
return valueExp.getValue(elContext);
{code}
Pedja -
Is there a tutorial for uploading fill- able forms to website and making them submit-table?
I want to upload a couple of fillable forms (pdf's) to website and allow customers to fill and submit. Is there a tutorial out there for this that someone could point me to? I can't seem to find one that really answers my questions.
A problem you'll encounter with those types of forms is security when transmitting the data. Obviously, the forms will contain sensitive information, and using email or a non-secure posting to a web server would not be acceptable. I personally would not send such data that way.
It's possible to set up the form and web server so that the data is submitted securely. If your web server can handle that, it would be the best way to go. You would have to somehow program the web server to manage it all. Now I'm being vague, but that's because there are a lot of details to consider. -
Error in Making Maintainenace Table
hi i am getting the following error while making the maintanace table for my Z Table.
<i>In DYNPFIELD_ATTR field LENGTH has the invalid value 250</i>
help me its urgent.
abhishek suppalHi abhishek ,
i think maximal length of a dynpro field is 132
(-> message SV 626)
Andreas -
I have a client who has asked me to make an entire web page
one big link. The web page is one big table with all the elements
inside the table. I figured making the entire table one big link
was the best way to do this, but I don't know if that's possible..
.and if so, how to do it. Is it? And if not, do I have any other
options? Thanks!
Julieor, do a screen capture of a browser view and save as a .jpg
and link the
.jpg. But, it seems like an odd request.
"Nancy" <[email protected]> wrote in message
news:gprl5i$8vv$[email protected]..
I guess .. but why would anyone do this? Try selecting the
table and put in
the link info and you should end up with the a tags
surrounding the table
tag.
I wouldn't do it tho.
Nancy Gill
Adobe Community Expert
Author: Dreamweaver 8 e-book for the DMX Zone
Co-Author: Dreamweaver MX: Instant Troubleshooter (August,
2003)
Technical Editor: Dreamweaver CS3: The Missing Manual,
DMX 2004: The Complete Reference, DMX 2004: A Beginner's
Guide
Mastering Macromedia Contribute
Technical Reviewer: Dynamic Dreamweaver MX/DMX: Advanced PHP
Web Development
"Kenford" <[email protected]> wrote in
message
news:gpr4o1$j2t$[email protected]..
>I have a client who has asked me to make an entire web
page one big link.
>The
> web page is one big table with all the elements inside
the table. I
> figured
> making the entire table one big link was the best way to
do this, but I
> don't
> know if that's possible.. .and if so, how to do it. Is
it? And if not, do
> I
> have any other options? Thanks!
>
> Julie
> -
Problem with CheckBox as table cell renderer
i m making a JTable having three columns.
i m also making a cellRenderer of my own MyRenderer
extending Jcheckbox and implementing TableCellRenderer
now i m setting MyRenderer as renderer for third column in my table and
DefaultCellEditor with jcheckbox as parameter as cell editor for this column
the code is like this--------------------
****making of JTable****
table= new JTable(3,3);
JScrollPane scrollPane = new JScrollPane(table);
TableColumn tableColumn = table.getColumn("Male"); // let us suppose that this gives third column
tableColumn.setCellRenderer(new MyRenderer ());
tableColumn.setCellEditor(new DefaultCellEditor(new JCheckBox()));
*****The classs implementing TableCellRenderer is given below******
class MyRenderer extends JCheckBox implements TableCellRenderer{
public MyRenderer(){
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column){
if(value != null){
Boolean booleanValue = (Boolean)value;
setSelected(booleanValue.booleanValue());
return this;
***********************************Problem****************************
The problem is that when we click on the cell of that column first time,
all the cells are selected.
I don't want to use getColumnClass() method for this problem .
If possible , please give some other solution.
what is the problem behind this,If anybody can help us.
Thanks in advance.I think the problem is, when the value is null the checkbox return with the selected state, b'coz u r
returning the checkbox (as it is). so pl'z try with below code (ADDED).
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus,
int row, int column){
if(value != null){
Boolean booleanValue = (Boolean)value;
setSelected(booleanValue.booleanValue());
else /// ADDED
setSelected(false);/// ADDED
return this;
Nediaph. -
How can I make this possible? Loading another html, into a table?
Hello everyone!
Im using Dreamweaver CS3. I have a website thats all image based - which is not good because google or any search engine cant really pick up any keywords. So I have a table filled with images, Id like to take an image in the center out, and put in some type of code that says "load blah.html into the current row and collumn of this table. I attached an image of what I mean.
Id like to do this because it will be easier for me to update 1 html file and have it load that into the master html file. Is this even possible?
If anyone is interested in checking out the source of the page im working on please feel free to go here:
http://www.ryandeyoung.com/home.html
Thanks in advance for anyones help.TheFiend1 wrote:
Well, I mean 1 row and 1 column, sorry - but when I go to type something in there it starts typing in the middle - is there a text field I can stick in that empty spot? Where I can write whatever and for it to be as long as I make it, without making the master table change in length?
Here's an example of some scrolling text inside a table cell...
http://dreamweaverresources.com/tutorials/scroller.html
Easy enough to see how it's done, I've provided the code :-)
You can set up the scrolling div in the table cell and then use an include file to populate the text into that div... that way,, you can make changes to the include file and it will be updated automatically on the page.
Here's a quick and easy article on creating server side includes (SSI). Use this to create your 'include file' that goes into that scrolling div.
http://bignosebird.com/ssi.shtml
Nadia
Adobe® Community Expert : Dreamweaver
Unique CSS Templates |Tutorials |SEO Articles
http://www.DreamweaverResources.com
Book: Ultimate CSS Reference
http://www.sitepoint.com/launch/005dfd4/3/133
http://twitter.com/nadiap
Maybe you are looking for
-
RFC_ERROR_SYSTEM_FAILURE during inbound processing
Hi, I am getting below error while using startrfc for inbound processing. RFC Call/Exception: SYSTEM_FAILURE Group Error group 104 Key RFC_ERROR_SYSTEM_FAILURE Message Port 'SAPCC4' does not exist in the table of port descriptions I
-
Streaming Video in Flash Builder 4.5 AIR for Android
How do you do it? When you try to use the VideoDisplay that is built-in for AIR, the documentation pops up and says: Adobe discourages using VideoDisplay when targeting profiles: mobileDevice. What are you supposed to use?
-
Interco Elimination in Legal application
Dear All, I understood that Inco elimination in legal application will be handled using business rule-adjustment details (Inco elimination) and will be triggered by stored procedure runcosole. Elimination entries will be posted at group level which w
-
Ipad Restore: If I restore to factory settings do I lose my game data?
I was having some issues with my iPad. The keyboard was slow and sometimes non-responsive. I have found a temperary fix but would like my iPad to be back to normal (or more so then now). I went to simply computing and was told to try restoring to fac
-
Showing iViews with Web Page Composer
Hi guys, I have to use iViews in a Web Page in Web Page Composer. I was searching some info in snd but i couldn't find anything about it. Can somebody help me? Best regards.