Compare commits
No commits in common. "827fa59bf9e0691a8c035bb4d8512f12bb570e68" and "1412505d334e48200d91b9fe68898aac9c4568bb" have entirely different histories.
827fa59bf9
...
1412505d33
|
@ -1,24 +1,9 @@
|
||||||
package lab5;
|
package lab5;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class Letter {
|
public class Letter {
|
||||||
private char symbol;
|
private char symbol;
|
||||||
|
|
||||||
public Letter(char symbol) {
|
public Letter(char symbol) {
|
||||||
this.symbol = 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,17 +2,8 @@ package lab5;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
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!");
|
System.out.println("Done!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package lab5;
|
package lab5;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class Word {
|
public class Word {
|
||||||
private Letter[] letters;
|
private Letter[] letters;
|
||||||
|
|
||||||
|
@ -17,17 +15,4 @@ public class Word {
|
||||||
letters[i] = new Letter(chars[i]);
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package lab6;
|
|
||||||
|
|
||||||
public class Jazz extends МузичнаКомпозиція {
|
|
||||||
public Jazz(int length) {
|
|
||||||
super(length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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!");
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package lab6;
|
|
||||||
|
|
||||||
public class Pop extends МузичнаКомпозиція {
|
|
||||||
public Pop(int length) {
|
|
||||||
super(length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
package lab6;
|
|
||||||
|
|
||||||
public class Rock extends МузичнаКомпозиція {
|
|
||||||
public Rock(int length) {
|
|
||||||
super(length);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
package lab6;
|
|
||||||
|
|
||||||
public class МузичнаКомпозиція {
|
|
||||||
/**
|
|
||||||
* Length in seconds
|
|
||||||
*/
|
|
||||||
private int length;
|
|
||||||
|
|
||||||
public МузичнаКомпозиція(int length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*public МузичнаКомпозиція() {
|
|
||||||
}*/
|
|
||||||
}
|
|
Loading…
Reference in New Issue