Compare commits

..

No commits in common. "827fa59bf9e0691a8c035bb4d8512f12bb570e68" and "1412505d334e48200d91b9fe68898aac9c4568bb" have entirely different histories.

8 changed files with 1 additions and 92 deletions

View File

@ -1,24 +1,9 @@
package lab5;
import java.util.Objects;
public class Letter {
private char symbol;
public Letter(char symbol) {
this.symbol = symbol;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Letter letter = (Letter) o;
return symbol == letter.symbol;
}
@Override
public int hashCode() {
return Objects.hash(symbol);
}
}

View File

@ -2,17 +2,8 @@ package lab5;
public class Main {
public static void main(String[] args) {
Word word = new Word("Hello");
Word word2 = new Word(new Letter[]{
new Letter('H'),
new Letter('e'),
new Letter('l'),
new Letter('l'),
new Letter('o'),
});
System.out.println(word.equals(word2));
System.out.println(word == word2);
System.out.println("Done!");
}

View File

@ -1,7 +1,5 @@
package lab5;
import java.util.Arrays;
public class Word {
private Letter[] letters;
@ -17,17 +15,4 @@ public class Word {
letters[i] = new Letter(chars[i]);
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Word word = (Word) o;
return Arrays.equals(letters, word.letters);
}
@Override
public int hashCode() {
return Arrays.hashCode(letters);
}
}

View File

@ -1,7 +0,0 @@
package lab6;
public class Jazz extends МузичнаКомпозиція {
public Jazz(int length) {
super(length);
}
}

View File

@ -1,16 +0,0 @@
package lab6;
public class Main {
public static void main(String[] args) {
МузичнаКомпозиція музичнаКомпозиція = new МузичнаКомпозиція(40);
МузичнаКомпозиція[] музичніКомпозиції = {
new МузичнаКомпозиція(60),
new Jazz(670),
new Pop(670),
new Rock(670),
};
музичнаКомпозиція = new Jazz(670);
System.out.println(музичнаКомпозиція.getClass().getSimpleName());
System.out.println("Done!");
}
}

View File

@ -1,7 +0,0 @@
package lab6;
public class Pop extends МузичнаКомпозиція {
public Pop(int length) {
super(length);
}
}

View File

@ -1,7 +0,0 @@
package lab6;
public class Rock extends МузичнаКомпозиція {
public Rock(int length) {
super(length);
}
}

View File

@ -1,15 +0,0 @@
package lab6;
public class МузичнаКомпозиція {
/**
* Length in seconds
*/
private int length;
public МузичнаКомпозиція(int length) {
this.length = length;
}
/*public МузичнаКомпозиція() {
}*/
}