first commit

This commit is contained in:
Boris
2024-01-15 20:14:10 +00:00
commit 8c81ee28b7
3106 changed files with 474415 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
#BlueJ class context
comment0.params=
comment0.target=MusicOrganizer()
comment0.text=\n\ Create\ a\ MusicOrganizer\n
comment1.params=filename
comment1.target=void\ addFile(java.lang.String)
comment1.text=\n\ Add\ a\ file\ to\ the\ collection.\n\ @param\ filename\ The\ file\ to\ be\ added.\n
comment2.params=
comment2.target=int\ getNumberOfFiles()
comment2.text=\n\ Return\ the\ number\ of\ files\ in\ the\ collection.\n\ @return\ The\ number\ of\ files\ in\ the\ collection.\n
comment3.params=index
comment3.target=void\ listFile(int)
comment3.text=\n\ List\ a\ file\ from\ the\ collection.\n\ @param\ index\ The\ index\ of\ the\ file\ to\ be\ listed.\n
comment4.params=index
comment4.target=void\ removeFile(int)
comment4.text=\n\ Remove\ a\ file\ from\ the\ collection.\n\ @param\ index\ The\ index\ of\ the\ file\ to\ be\ removed.\n
numComments=5

View File

@@ -0,0 +1,62 @@
import java.util.ArrayList;
/**
* A class to hold details of audio files.
*
* @author David J. Barnes and Michael Kölling
* @version 2016.02.29
*/
public class MusicOrganizer
{
// An ArrayList for storing the file names of music files.
private ArrayList<String> files;
/**
* Create a MusicOrganizer
*/
public MusicOrganizer()
{
files = new ArrayList<>();
}
/**
* Add a file to the collection.
* @param filename The file to be added.
*/
public void addFile(String filename)
{
files.add(filename);
}
/**
* Return the number of files in the collection.
* @return The number of files in the collection.
*/
public int getNumberOfFiles()
{
return files.size();
}
/**
* List a file from the collection.
* @param index The index of the file to be listed.
*/
public void listFile(int index)
{
if(index >= 0 && index < files.size()) {
String filename = files.get(index);
System.out.println(filename);
}
}
/**
* Remove a file from the collection.
* @param index The index of the file to be removed.
*/
public void removeFile(int index)
{
if(index >= 0 && index < files.size()) {
files.remove(index);
}
}
}

View File

@@ -0,0 +1,17 @@
Project: music-organizer-v1. A project to collect audio files.
Authors: David J. Barnes and Michael Kölling
This project is part of the material for the book
Objects First with Java - A Practical Introduction using BlueJ
Sixth edition
David J. Barnes and Michael Kölling
Pearson Education, 2016
It is discussed in chapter 4.
To start:
Create a MusicOrganizer object on the object bench.
Use its methods to add, show, and remove files.

View File

@@ -0,0 +1,29 @@
#BlueJ package file
objectbench.height=100
objectbench.width=757
package.editor.height=379
package.editor.width=954
package.editor.x=70
package.editor.y=80
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.editor.height=649
readme.editor.width=817
readme.editor.x=46
readme.editor.y=23
target1.editor.height=702
target1.editor.width=785
target1.editor.x=72
target1.editor.y=84
target1.height=60
target1.name=MusicOrganizer
target1.naviview.expanded=true
target1.showInterface=false
target1.type=ClassTarget
target1.typeParameters=
target1.width=120
target1.x=180
target1.y=110