The Artima Developer Community
Sponsored Link

Java Answers Forum
lil more on Arraylist NoteBook

2 replies on 1 page. Most recent reply: Mar 13, 2002 10:07 PM by Bill Venners

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
Hoody

Posts: 33
Nickname: hoodlum
Registered: Feb, 2002

lil more on Arraylist NoteBook Posted: Mar 13, 2002 7:40 PM
Reply to this message Reply
Advertisement
this is the main program but i also made a note class that inputs the note

import java.util.ArrayList;
 
/**
 * Notebook is a class that the user can enter notes into and can later list all the notes in the notebook.
 *
*/
 
public class NoteBook
{
    // instance variables 
    private ArrayList noteBook;
    private int numberOfNotes = 0;
    int urgentNotes;
   
    
 
    /**
     * Constructor for objects of class NoteBook
     */
    public NoteBook()
    {
        // initialise instance variables
        
        noteBook = new ArrayList ();
        
    }
    /**
     * Insert a note to the notebook.
     * @param newNote the note to add
     */
    public void insertNote(Note newNote) 
                    
    {
        noteBook.add(newNote);        
        
        
        
    }
 
     /**
     * Remove the note with number 'noteNumber' from the notebook.
     * If there is no note with such a number, just return.
     */
    public void removeNote(int noteNumber)
              throws Exception
    {                     
        if  (noteNumber < 0 || noteNumber > noteBook.size())        
         {
            throw new IllegalNumberException(noteNumber);
         }
       else 
            noteBook.remove(noteNumber);
           
    }   
 
    
     
    /**
     * Return the number of notes currently in the notebook.
     */
    public int numberOfNotes()
    {   
       
        for (int i = 0; i < noteBook.size(); i++)
        {
           numberOfNotes = noteBook.size() ;
        }
           
        return numberOfNotes;
    }
 
    /**
     * Return the number of notes in the notebook with the highest priority(priority#5).
     */
    public int urgentNotes()
    {   
        
        return urgentNotes;
    }
      
 
    /**
     * List all notes in the notebook with a number associate with each note.
     */
    
    public void listAll()   
    {  
        for(int i = 0; i < noteBook.size(); i++)
        {
 
            System.out.println(i + ". " + noteBook.get(i));
        }
    }    
         
   
}
i made a method to put priority numbers next to the note and the highest priority number is 5 so now i have to make a method return the number of priority numbers that are of high priority#5 this is similar to the numberofnotes but i need to specfically count the number of notes that equal priority#5 ..how exactly would i do that 
 
 


Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: lil more on Arraylist NoteBook Posted: Mar 13, 2002 10:05 PM
Reply to this message Reply
Dang, looks like Bob figured out a way to defeat my attempts at preventing runaway pages. What happened is he stuck the entire last paragraph within a [ java ] ... [/ java ] section. The only way I can prevent that is to put in a line break on long lines in [ java ] or [ pre ] sections. That will end up chopping up people's code, though. Hmm...

Bill Venners

Posts: 2284
Nickname: bv
Registered: Jan, 2002

Re: lil more on Arraylist NoteBook Posted: Mar 13, 2002 10:07 PM
Reply to this message Reply
To my surprise, only the initial post with the long line inside a [ java ] section displays wide, at least in IE on the Mac. My reply looked fine, so maybe I should leave things as they are.

Flat View: This topic has 2 replies on 1 page
Topic: Windows XP and Windows 64-bit OS Vs JAVA Previous Topic   Next Topic Topic: Problem with jar archive

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use