managing data l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Managing Data PowerPoint Presentation
Download Presentation
Managing Data

Loading in 2 Seconds...

play fullscreen
1 / 6

Managing Data - PowerPoint PPT Presentation


  • 319 Views
  • Uploaded on

Managing Data Databases Arrays, Lists, and File I/O An Array-based database public static String Artist[] = new String[ 5 ]; public static String Song[] = new String[ 5 ]; public static int length = 0 ; public static void main ( String [] args) { length = Artist.length;

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Managing Data' - Ava


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
managing data

Managing Data

Databases

Arrays, Lists, and File I/O

an array based database
An Array-based database

public static String Artist[] = new String[5];

public static String Song[] = new String[5];

public static int length = 0;

public static void main(String [] args)

{

length = Artist.length;

Artist[0] = "System of a Down";

Song[0] = "Hypnotize";

Artist[1] = "Every Time I Die";

Song[1] = "Kill the Music";

// etc……

what s wrong with this
What’s wrong with this
  • Two arrays must be synchronized
  • Filling the arrays with Artists and Songs is done IN THE CODE. Bad.
  • One more thing….
sorting
Sorting

public static void sortByArtist()

{

for (int y = 0; y<length; y++)

{

for (int z = 0; z<y; z++)

{

if ( Artist[z].compareTo(Artist[y]) > 0)

{

swap( y,z);

}// end if

} // end for z

} // end for y

} // end sort by artist

swap permanently moves items
Swap –permanently moves items

public static void swap( int a, int b) { String temp; temp = Artist[a]; Artist[a] = Artist[b]; Artist[b] = temp; temp = Song[a]; Song[a] = Song[b]; Song[b] = temp; }

step 1 get information from files
Step 1 – get information from files

Put all the database info into a file, rather than in your code.