Commit f4346fe2 authored by 9931099's avatar 9931099

first comment

parents
Pipeline #5904 failed with stages
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../:\UniVersity\Term2\A.P lab\Session 3\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Session 3.iml" filepath="$PROJECT_DIR$/Session 3.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/clock-display" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/music-organizer" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\UniVersity\Term2\A.P lab\Session 3\clock-display\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/clock-display.iml" filepath="$PROJECT_DIR$/clock-display.iml" />
</modules>
</component>
</project>
\ No newline at end of file
/**
* The ClockDisplay class implements a digital clock display for a
* European-style 24 hour clock. The clock shows hours and minutes. The
* range of the clock is 00:00 (midnight) to 23:59 (one minute before
* midnight).
*
* The clock display receives "ticks" (via the timeTick method) every minute
* and reacts by incrementing the display. This is done in the usual clock
* fashion: the hour increments when the minutes roll over to zero.
*
* @author Michael Kolling and David J. Barnes
* @version 2008.03.30
*/
public class ClockDisplay
{
private NumberDisplay hours;
private NumberDisplay minutes;
private NumberDisplay seconds;
private String displayString; // simulates the actual display
/**
* Constructor for ClockDisplay objects. This constructor
* creates a new clock set at 00:00.
*/
public ClockDisplay()
{
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
seconds = new NumberDisplay(60);
updateDisplay();
}
/**
* Constructor for ClockDisplay objects. This constructor
* creates a new clock set at the time specified by the
* parameters.
*/
public ClockDisplay(int hour, int minute,int second)
{
hours = new NumberDisplay(24);
minutes = new NumberDisplay(60);
seconds = new NumberDisplay(60);
setTime(hour, minute , second);
}
/**
* This method should get called once every minute - it makes
* the clock display go one minute forward.
*/
public void timeTick()
{
seconds.increment();
if(seconds.getValue()==0){
minutes.increment();
if(minutes.getValue() == 0) { // it just rolled over!
hours.increment();
}
}
//updateDisplay();
// minutes.increment();
updateDisplay();
}
/**
* Set the time of the display to the specified hour and
* minute.
*/
public void setTime(int hour, int minute,int second)
{
hours.setValue(hour);
minutes.setValue(minute);
seconds.setValue(second);
updateDisplay();
}
/**
* Return the current time of this display in the format HH:MM.
*/
public String getTime()
{
return displayString;
}
/**
* Update the internal string that represents the display.
*/
private void updateDisplay()
{
displayString = hours.getDisplayValue() + ":" +
minutes.getDisplayValue()+":"+seconds.getDisplayValue();
}
public static void main(String[] args) throws InterruptedException {
ClockDisplay clock = new ClockDisplay();
for(int i=0;i<10;i++){
Thread.sleep(1000);
clock.timeTick();
System.out.println(clock.getTime());
}
}
}
/**
* The NumberDisplay class represents a digital number display that can hold
* values from zero to a given limit. The limit can be specified when creating
* the display. The values range from zero (inclusive) to limit-1. If used,
* for example, for the seconds on a digital clock, the limit would be 60,
* resulting in display values from 0 to 59. When incremented, the display
* automatically rolls over to zero when reaching the limit.
*
* @author Michael Kolling and David J. Barnes
* @version 2008.03.30
*/
public class NumberDisplay
{
private int limit;
private int value;
/**
* Constructor for objects of class NumberDisplay.
* Set the limit at which the display rolls over.
*/
public NumberDisplay(int rollOverLimit)
{
limit = rollOverLimit;
value = 0;
}
/**
* Return the current value.
*/
public int getValue()
{
return value;
}
/**
* Return the display value (that is, the current value as a two-digit
* String. If the value is less than ten, it will be padded with a leading
* zero).
*/
public String getDisplayValue()
{
if(value < 10) {
return "0" + value;
}
else {
return "" + value;
}
}
/**
* Set the value of the display to the new specified value. If the new
* value is less than zero or over the limit, do nothing.
*/
public void setValue(int replacementValue)
{
if((replacementValue >= 0) && (replacementValue < limit)) {
value = replacementValue;
}
}
/**
* Increment the display value by one, rolling over to zero if the
* limit is reached.
*/
public void increment()
{
value = (value + 1) % limit;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\UniVersity\Term2\Kargah A.P\Session 3\music-organizer\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/music-organizer.iml" filepath="$PROJECT_DIR$/music-organizer.iml" />
</modules>
</component>
</project>
\ No newline at end of file
import java.util.ArrayList;
/**
* a class to storemusic files details better
*
* @author fazel
*
* @version 1.0
*/
public class Music {
//music name
private String name;
//name of the producer
private String producer;
//year of production
private int publishYear;
//music file address
private String address;
/**
* creates a music
*
*
* @param name
* @param producer
* @param publishYear
* @param address
*/
public Music(String name, String producer, int publishYear, String address) {
this.name = name;
this.producer = producer;
this.publishYear = publishYear;
this.address = address;
}
/**
* prints data
*/
public void printData(){
System.out.println("name: "+name);
System.out.println("address: "+address);
System.out.println("producer: "+producer);
System.out.println("publish year: "+publishYear);
}
/**
*
* @return name
*/
public String getName() {
return name;
}
public String getProducer() {
return producer;
}
public String getAddress() {
return address;
}
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Scanner;
/**
* A class to hold details of audio files.
*
* @author David J. Barnes and Michael K�lling
* @version 2011.07.31
*/
public class MusicCollection
{
// An ArrayList for storing the file names of music files.
private ArrayList<Music> files;
// A player for the music files.
private MusicPlayer player;
//fav musics list
private ArrayList<Music> favorateMusics;
/**
* Create a MusicCollection
*/
public MusicCollection()
{
files=new ArrayList<Music>();
favorateMusics=new ArrayList<>();
}
/**
* Add a file to the collection.
* @param filename The file to be added.
*/
public void addFile(String filename)
{
Scanner scanner= new Scanner(System.in);
System.out.println("name of producer");
String producer=scanner.nextLine();
System.out.println("address");
String address=scanner.nextLine();
System.out.println("publish year");
int publish=scanner.nextInt();
scanner.nextLine();
files.add(new Music(filename,producer,publish,address));
}
/**
* Return the number of files in the collection.
* @return The number of files in the collection.
*/
public int getNumberOfFiles()
{
int i =files.size();
return i;
}
/**
* List a file from the collection.
* @param index The index of the file to be listed.
*/
public void listFile(int index)
{
files.get(index).printData();
}
/**
* Show a list of all the files in the collection.
*/
public void listAllFiles()
{
for (int i=0;i<files.size();i++) {
System.out.println("Song "+(i+1)+":");
files.get(i).printData();
}
}
/**
* Remove a file from the collection.
* @param index The index of the file to be removed.
*/
public void removeFile(int index)
{
files.remove(index);
}
/**
* Start playing a file in the collection.
* Use stopPlaying() to stop it playing.
* @param index The index of the file to be played.
*/
public void startPlaying(int index)
{
if(validIndex(index))
System.out.println("song "+files.get(index).getName()+" is playing now");
}
/**
* Stop the player.
*/
public void stopPlaying()
{
System.out.println("player is stopped!");
}
/**
* Determine whether the given index is valid for the collection.
* Print an error message if it is not.
* @param index The index to be checked.
* @return true if the index is valid, false otherwise.
*/
private boolean validIndex(int index)
{
// The return value.
// Set according to whether the index is valid or not.
if((index>=0)&&(index<files.size()))
return true;
else{
System.out.println("an error occoured");
return false;
}
}
/**
* adds a song to favorite list by its original index
* @param index
*/
public void addToFavorateMusics(int index){
favorateMusics.add(files.get(index));
}
/**
* removes a song in the favorite list by its index
* @param index
*/
public void removeFromFavorate(int index){
favorateMusics.remove(files.get(index));
}
/**
* prints the favorite list
*/
public void showFavorateList(){
Iterator<Music> it=favorateMusics.iterator();
int i=1;
while(it.hasNext()){
System.out.println("Song "+i+":");
it.next().printData();
i++;
}
}
/**
* searches a song name and prints all available matched songs
* @param name
*/
public void Search(String name){
Iterator<Music> it=files.iterator();
while (it.hasNext()){
if(it.next().getName().equals(name)){
System.out.println("name :"+it.next().getName());
System.out.println("address :"+it.next().getAddress());
System.out.println("producer :"+it.next().getProducer());
}
}
}
public static void main(String[] args) {
MusicCollection hiphop = new MusicCollection();
MusicCollection pop = new MusicCollection();
hiphop.files.add(new Music("dramasetter","eminem",2013,"E://Musics"));
hiphop.files.add(new Music("Arcade","duncan Laurence",2020,"E://Musics"));
hiphop.files.add(new Music("paid my dues","NF",2021,"E://Musics"));
hiphop.files.add(new Music("drive forever","serigio valentino",2021,"E://Musics"));
hiphop.files.add(new Music("stereo hearts","gym class heroes",2021,"E://Musics"));
hiphop.files.add(new Music("Criminal","Eminem",2021,"E://Musics"));
hiphop.listAllFiles();
hiphop.removeFile(1);
System.out.println("");
System.out.println("");
System.out.println("");
hiphop.listAllFiles();
hiphop.addToFavorateMusics(0);
hiphop.addToFavorateMusics(1);
hiphop.addToFavorateMusics(2);
//hiphop.listAllFiles();
hiphop.showFavorateList();
hiphop.removeFromFavorate(0);
hiphop.showFavorateList();
hiphop.startPlaying(2);
hiphop.stopPlaying();
}
}
\ No newline at end of file
/**
* Provide basic playing of MP3 files via the javazoom library.
* See http://www.javazoom.net/
*
* @author David J. Barnes and Michael Klling.
* @version 2011.07.31
*/
public class MusicPlayer
{
// The current player. It might be null.
private boolean isPlaying;
/**
* Constructor for objects of class MusicFilePlayer
*/
public MusicPlayer()
{
isPlaying = false;
}
/**
* Start playing the given audio file.
* The method returns once the playing has been started.
* @param filename The file to be played.
*/
public void startPlaying(String filename)
{
System.out.println(filename + " is playing...");
isPlaying = true;
}
public void stop()
{
System.out.println("player is stopped!");
isPlaying = false;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\UniVersity\Term2\Kargah A.P\Session 3\music-organizer\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/music-organizer.iml" filepath="$PROJECT_DIR$/music-organizer.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\UniVersity\Term2\Kargah A.P\Session 3\music-organizer\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/music-organizer.iml" filepath="$PROJECT_DIR$/music-organizer.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../../../:\UniVersity\Term2\Kargah A.P\Session 3\music-organizer\.idea/dataSources/
/dataSources.local.xml
# Editor-based HTTP Client requests
/httpRequests/
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/music-organizer.iml" filepath="$PROJECT_DIR$/music-organizer.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment