This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function initialName(name, length) { | |
const parts = name.split(' '); | |
return parts.filter((it, i) => i <= (length - 1)).map(it => it.substring(0, 1)).join(''); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package circle | |
import ( | |
"testing" | |
) | |
func TestDiameter(t *testing.T) { | |
circle := Circle{Radius: 7} | |
expected := 14.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package circle | |
import ( | |
"testing" | |
) | |
func TestArea(t *testing.T) { | |
circle := Circle{Radius: 10} | |
expected := 314.1592653589793 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package circle | |
import ( | |
"math" | |
) | |
type Circle struct { | |
Radius float64 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void create(String title, String content) { | |
String key = mNoteRef.push().getKey(); | |
Note note = new Note(key, title, content); | |
mNoteRef.child(key).setValue(note); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ValueEventListener valueEventListener = new ValueEventListener() { | |
@Override | |
public void onDataChange(DataSnapshot dataSnapshot) { | |
ArrayList<Note> notes = new ArrayList<Note>(); | |
for (DataSnapshot noteSnapshot: dataSnapshot.getChildren()) { | |
Note note = noteSnapshot.getValue(Note.class); | |
notes.add(note); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IgnoreExtraProperties | |
public class Note { | |
private String uid; | |
private String title; | |
private String content; | |
public Note() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void case13() { | |
ArrayList<User> users = new ArrayList<User>(); | |
users.add(new User(1, "Adimas Lutfi Wicaksono")); | |
users.add(new User(2, "Salman Alfarisi")); | |
users.add(new User(3, "Muhammad Sholeh")); | |
ArrayList<User> usersDeleted = new ArrayList<User>(); | |
usersDeleted.add(new User(2, "Salman Alfarisi")); | |
usersDeleted.add(new User(3, "Muhammad Sholeh")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void case12() { | |
ArrayList<User> users = new ArrayList<User>(); | |
users.add(new User(1, "Adimas Lutfi Wicaksono", 1)); | |
users.add(new User(2, "Salman Alfarisi", 1)); | |
users.add(new User(3, "Muhammad Sholeh", 1)); | |
users.add(new User(4, "Yadi Cahyadi", 1)); | |
users.add(new User(5, "Maya Maulani", 2)); | |
} | |
private class User { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void case14() { | |
ArrayList<User> users = new ArrayList<User>(); | |
users.add(new User(1, "Adimas Lutfi Wicaksono")); | |
users.add(new User(2, "Salman Alfarisi")); | |
users.add(new User(3, "Muhammad Sholeh")); | |
ArrayList<User> usersNew = new ArrayList<User>(); | |
usersNew.add(new User(4, "Yadi Cahyadi")); | |
usersNew.add(new User(5, "Maya Maulani")); |
NewerOlder