Category Archives: Computer Science

Bank Runner Class

Bank Class

This is a modified version of this bank assignment

The responsibilities of this class are to

  • Methods
    • Person[] topAccountOwners(int number )
      • this method returns the  top number  owners with the greatest amount of cash in 1 account
    • ** boolean binarySearch( int accountNumber)  // this method should implement the binary search algorithm to determine if the account acct exists . Note for binary search to work, what must be true?
    • ** extra credit  Account[] sortByAccountId()
      •   this method returns an array of Accounts sorted by amount in the account

 

 

Compiled and Interpreted Languages

Comilers and Interpreters

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

java-compiler-interpreter

retrieved from http://www.greenteapress.com/thinkapjava/html/thinkjava003.html

 

compiler_interpreter

retrieved from http://www.pasteur.fr/formation/infobio/python/ch05s02.html

 

Playlist Project [Array]

A PlayList project will be based on Three Classes

The Artist class will store core information about an artist

The Song class will store basic information about a music song

The PlayList class will manage lists of songs and artists


 

Artist

  • Constructor(s) :
    public Artist( String name) { //missing code }

 

  • Instance Variables (“global” variables)

 

Methods

 


 

Song

Constructor(s):

Instance Variables

example of how to get current milliseconds as a long

Method

 


 

Artist

Song

PlayList


 

PlayList

  • Instance Variables
    • private String listName : This is the ‘name’ of your playList
    • private Song[] songs;
    • private  int[] stars ; //how many stars each song has between 0 and 5 inclusive.
    • Note: songs and stars are parallel Arrays
  • Constructor
    • public PlayList(String name) : There should be only 1 constructor that takes a parameter representing the name of the playList
  • Accessor Methods
    • public double averageRating() // returns the average star rating for the list
    • public double averageRating(Artist artist)  // returns the mean star rating associated with artist
    • public Song[] getSongs(Artist artist) // returns an array populated by the songs of the parameter artist
    • public Song[] getSongs() // returns all the songs in the list

    Mutator Methods

    • public void swap(Song song1 ,  Song song2 )  // switches positions of these two (maintain parallelism!)
    • public void  add(Song song , int stars)
    • public void removeSong(Song song, String artist )  //removes song associated with artist
      • Note: Be careful here. You are allowed to add the same song and artist. Duplicates are allowed.
    • public void removeArtist(Artist artist ) //removes all elements associated with artist
    • public void removeLowStars(int cutOff) //removes all elements associated with a star rating less than cutOff
    •  ** public PlayList sortByDate() //this returns a rearranged PlayList based on each Song’s date
    • ** public PlayList sortByRating() //this returns a rearranged playlist so that the 5 starred elements are the first group in the list, 4 stars second …1 stars, last
    • ** public PlayList shuffle() //this returns a new PlayList in which all of the songs have been reordered randomly.

Artist

Song

PlayList

Representing Data

Representing Data

You will be responsible for understanding the core concepts behind all the formats/file types (listed in chapter 3 of the book for representing for various types of data (text, images, video), the pros and cons of different formats and when it is appropriate to use different formats. For instance, jpg’s are meant to realistically represent photographs and use color averaging, while GIF’s have a max  of 256 colors and therefore  have much smaller file sizes than jpegs ; the latter are not a good choice for representing photographs but rather for cartoons or line art. Both of these are Raster not vector shapes.

Representing Graphics

Video