Commit cecb6bdf authored by 9831067's avatar 9831067

Add project to git

parents
Pipeline #2616 failed with stages
File added
import java.util.ArrayList;
import java.util.Iterator ;
import java.util.ArrayList;
public class MusicOrganizer {
private ArrayList<String> tracks;
public void removeTrack(String nameLike) {
for (int i = 0; i < tracks.size(); i++)
if(tracks.get(i).contains(nameLike)) {
tracks.remove(i);
break ;
}
}
}
/*
public class MusicOrganizer {
private ArrayList<String> tracks;
public void removeTrack(String nameLike) {
Iterator<String> it = tracks.iterator() ;
while ( it.hasNext() ){
if(it.next().contains(nameLike))
tracks.remove(it) ;
}
}
}
*/
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>project23-part1-9831067</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
/**
* 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();
}
/**
* 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() ;
}
}
/**
* 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;
}
}
import java.time.format.DateTimeFormatter;
import java.time.LocalDateTime;
public class Run {
public static void main(String[] args){
/**
* The LocalDateTime.now() method returns the instance
* of LocalDateTime class. If we print the instance of
* LocalDateTime class, it prints current date and time.
* To format the current date, you can use DateTimeFormatter
* class which is included in JDK 1.8.
*/
DateTimeFormatter dtf = DateTimeFormatter.ofPattern(" HH:mm:ss");
LocalDateTime now = LocalDateTime.now();
String nowDateTime = dtf.format(now) ;
int hour = Integer.parseInt(nowDateTime.substring(11,13)) ;// convert to int
int min = Integer.parseInt(nowDateTime.substring(14,16)) ;//convert to int
int sec = Integer.parseInt(nowDateTime.substring(17,19)) ;// convert to int
ClockDisplay Clock = new ClockDisplay(hour,min,sec) ;
System.out.println("nowTime : ");
System.out.println(Clock.getTime());
Clock.timeTick();
System.out.println("AfterTimeTick : ");
System.out.println(Clock.getTime());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>group22-part2-9831067</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
/**
*
* @author Ali
*
*/
public class Music {
//name of the music
private String musicName ;
//name of the singer of the music
private String singerName ;
//year of the produce of the music
private int yearOfProduce ;
/**
* Create a new music and allocate a memory for music information
*/
public Music() {
musicName = new String() ;
singerName = new String();
}
/**
* create a new music and
* Set the information of music
*
* @param musicName Name of the music
* @param singerName Name of the singer
* @param yearOfProduce
*/
public Music(String musicName , String singerName , int yearOfProduce) {
this.musicName = new String() ;
this.singerName = new String();
this.musicName = musicName ;
this.singerName = singerName ;
this.yearOfProduce = yearOfProduce ;
}
/**
* Set the information of music
*
* @param musicName Name of the music
*/
public void setMusicName(String musicName) {
this.musicName = musicName ;
}
/**
* @param singerName singer of the music
*/
public void setMusicSinger(String singerName) {
this.singerName = singerName ;
}
/**
* @param yearOfProduce year of produce of the music
*/
public void setMusicYear(int yearOfProduce) {
this.yearOfProduce = yearOfProduce ;
}
/**
* get the music Name
* @return
*/
public String getMusicName(){
return musicName ;
}
/**
* get the singer of music
* @return
*/
public String getMusicSinger() {
return singerName ;
}
/**
* get the year of produce
* @return
*/
public int getMusicYear() {
return yearOfProduce ;
}
}
import java.util.ArrayList;
/**
* 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;
/**
* Create a MusicCollection
*/
public MusicCollection()
{
files = new ArrayList<Music>() ;
player = new MusicPlayer() ;
}
/**
* Add a file to the collection.
* @param filename The file to be added.
*/
public void addFile(Music music)
{
files.add(music) ;
}
/**
* 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(validIndex(index)) {
System.out.println("MusicName is"
+ files.get(index).getMusicName()
+ "singerName is : "
+ files.get(index).getMusicSinger()
+ "yearOfProduce is : "
+ files.get(index).getMusicYear() );
}
else
System.out.println("Index is not valid!");
}
/**
* Show a list of all the files in the collection.
*/
public void listAllFiles(String kindOfSong)
{
System.out.println("In a "+kindOfSong+" collection these are our songs\n");
for(Music it : files) {
System.out.println("MusicName is: "
+ it.getMusicName()
+ " singerName is : "
+ it.getMusicSinger()
+ " yearOfProduce is : "
+ it.getMusicYear()+ "" );
}
System.out.println() ;
}
/**
* Remove a file from the collection.
* @param index The index of the file to be removed.
*/
public void removeFile(int index)
{
if(validIndex(index))
files.remove(index) ;
else
System.out.println("Index is not valid!");
}
/**
* 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)) {
String fileName = files.get(index).getMusicName() ;
player.startPlaying(fileName);
}
else
System.out.println("Index is not valid!");
}
/**
* Stop the player.
*/
public void stopPlaying()
{
player.stop();
}
/**
* 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 )
return false ;
else if( index < getNumberOfFiles())
return true ;
else
return false ;
}
/**
* Search the music with entering Name or NameOfSinger of music
* @param str Name or Name of singer that we enter
*
*/
public void searchMusic(String str) {
// to determine searchResult is true or false
boolean searchResult = false ;
System.out.println("Result of search :");
for(Music it : files) {
if(it.getMusicName().equals(str) || it.getMusicSinger().equals(str) ) {
System.out.println("The music was found! :-)");
System.out.println("MusicNameIs: "
+ it.getMusicName()
+ " SingerNameIs: "
+ it.getMusicSinger()
+ " YearOfProduce: "
+ it.getMusicYear());
searchResult = true ;
break ;
}
}
if(searchResult == false)
System.out.println("The Music Not found!");
}
}
\ 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
public class Run{
public static void main (String[] args) {
MusicCollection pop = new MusicCollection() ;
MusicCollection rock = new MusicCollection() ;
MusicCollection jazz = new MusicCollection() ;
MusicCollection country = new MusicCollection() ;
MusicCollection favorite = new MusicCollection() ;
Music pop1 = new Music("Ali", "alioiii", 2020) ;
Music pop2 = new Music("poorya", "poooooory", 2019) ;
Music pop3 = new Music("peyman", "peyyyyman", 2017) ;
Music pop4 = new Music("pariiii", "paariiii", 2010) ;
pop.addFile(pop1) ;
pop.addFile(pop2);
pop.addFile(pop3);
pop.addFile(pop4);
pop.listAllFiles("pop");
pop.removeFile(2);
pop.listAllFiles("pop");
favorite.addFile(pop1);
favorite.addFile(pop3);
favorite.listAllFiles("favorite");
pop.startPlaying(0);
pop.searchMusic("paarii");
}
}
\ 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