id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
829b5c3d-0877-4540-a0da-2b68333f35ff | public void setBasicAutenticationStatus(String basicAutenticationStatus) {
this.basicAutenticationStatus = basicAutenticationStatus;
} |
324ae5f0-6d56-4ab9-bb8a-f8f2fab520b2 | public String getKnowledgeAgentName() {
return knowledgeAgentName;
} |
9a4ec4a8-775a-4c69-810c-782fafa320e5 | public void setKnowledgeAgentName(String knowledgeAgentName) {
this.knowledgeAgentName = knowledgeAgentName;
} |
18dbc7b8-d9c4-4848-980e-5431ed1c00d1 | public DroolsException(String message) {
super(message);
} |
336fe71c-0f1f-4eca-8ee7-22890f89550e | public BrmsException(String message){
super(message);
} |
aba6e18d-c4f3-40b4-91bf-483819ab7ea1 | public JLife() {
setLayout(new BorderLayout());
add(new JLifeControls(this), BorderLayout.SOUTH);
add(world = new JLifeWorld(200, 200, 2), BorderLayout.CENTER);
timer = new Timer(1000, this);
} |
60405d54-3feb-422d-a862-93345b2e20ca | public void fillWorldRandomly() {
world.fillRandomly();
} |
5fdef91e-f03c-421b-8d60-f6890bc2cda1 | @Override
public void actionPerformed(ActionEvent event) {
world.tick();
} |
badd71f0-b05f-4b90-807c-be194133b3b9 | public void setSpeed(int speed) {
timer.setDelay(speed);
} |
b2905d35-5ea1-4ee7-828f-d01302edd76e | public boolean isRunning() {
return timer.isRunning();
} |
1724fbeb-e5fa-4e6d-bb85-4c162cd3b45f | public void start() {
timer.start();
} |
27816e8a-bbc1-4b0a-b0b0-8d386623d2b0 | public void stop() {
timer.stop();
} |
50c62f42-3050-4bf0-a5cb-fd79d09d875a | protected JLifeControls(JLife lifeInstance) {
this.lifeInstance = lifeInstance;
bundle = ResourceBundle.getBundle("ControlsBundle");
add(createStartStopButton());
add(createFillRandomlyButton());
add(createSpeedSlider());
setLayout(new FlowLayout(FlowLayout.LEFT));
} |
a241c8d4-12b3-4ff4-9de4-2d4404ec6eb7 | private JButton createStartStopButton() {
final JButton startStopButton = new JButton();
startStopButton.setText(bundle.getString("button.start"));
startStopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (lifeInstance.isRunn... |
483c0648-f40b-4ee7-940c-c01f55bc37c3 | @Override
public void actionPerformed(ActionEvent event) {
if (lifeInstance.isRunning()) {
lifeInstance.stop();
startStopButton.setText(bundle.getString("button.start"));
}
else {
lifeInstance.start();
startStopButton.setText(bundle.getString("button... |
ca6a71fb-d66e-467b-9d92-c60c285743b3 | private JButton createFillRandomlyButton() {
JButton fillRandomlyButton = new JButton();
fillRandomlyButton.setText(bundle.getString("button.fill-random"));
fillRandomlyButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
lifeInstanc... |
1d1efdad-0bc9-47a6-9d14-2e45cdbd9970 | @Override
public void actionPerformed(ActionEvent event) {
lifeInstance.fillWorldRandomly();
} |
9f54a655-079f-4406-a577-3f0db31c99fd | private JSlider createSpeedSlider() {
DefaultBoundedRangeModel model = new DefaultBoundedRangeModel();
model.setMinimum(1);
model.setMaximum(1000);
model.setValue(1000);
final JSlider speedSlider = new JSlider();
speedSlider.setModel(model);
speedSlider.addChangeListener(new ChangeListener(... |
a339afd3-ce5d-4c2f-a98f-f318b255a886 | @Override
public void stateChanged(ChangeEvent event) {
lifeInstance.setSpeed(speedSlider.getValue());
} |
618904a0-3c9d-403a-a9a4-69ef213a2d82 | public static void main(String[] args) {
JFrame frame = new JFrame("Game Of Life");
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JLife());
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
} |
a56e3b5f-81db-4fb7-913b-695b7496b5bd | @Override
public void init() {
life = new JLife();
} |
b758b063-3e46-482f-a9f8-a121db1c2d36 | @Override
public void start() {
add(life);
} |
c0c8cfd9-f164-49d8-8a54-34d3d9455b9f | private JLifeWorld() {
random = new Random();
} |
5556dd61-2ff7-401e-a622-fe716d1c4a87 | protected JLifeWorld(int gridWidth, int gridHeight, int cellSize) {
this();
setGridWidth(gridWidth);
setGridHeight(gridHeight);
setCellSize(cellSize);
this.currentGeneration = new boolean[gridWidth][gridHeight];
this.nextGeneration = new boolean[gridWidth][gridHeight];
int width = gridWid... |
8a22c980-39ef-4d37-b71e-233bdce2c8c7 | public void setGridWidth(int gridWidth) {
if (gridWidth <= 0) {
throw new IllegalArgumentException("gridWidth must be above 0");
}
this.gridWidth = gridWidth;
} |
6f822e05-35b9-4053-97fb-aefa6cc8c2d9 | public void setGridHeight(int gridHeight) {
if (gridHeight <= 0) {
throw new IllegalArgumentException("gridHeight must be above 0");
}
this.gridHeight = gridHeight;
} |
66d50ccc-e2f4-4206-b33f-29e33cc96eb9 | public int getGridWidth() {
return gridWidth;
} |
b3afae2c-c819-4225-a67e-2d1c5d2f9eba | public int getGridHeight() {
return gridHeight;
} |
af0a774b-ccd5-43d8-a559-fa0658adc9f2 | public int getCellSize() {
return cellSize;
} |
b7afa522-7d1c-442a-a2d8-c363664a2823 | public void setCellSize(int cellSize) {
if (cellSize <= 0) {
throw new IllegalArgumentException("cellSize must be > 0");
}
this.cellSize = cellSize;
} |
92f68431-094f-47b0-8000-1aec3fca3e79 | public boolean isInWorld(int x, int y) {
return (x > 0 && x < gridWidth) && (y > 0 && y < gridHeight);
} |
c03bf278-72e4-4282-9adc-5e1287efee37 | public boolean isAlive(int x, int y) {
return isInWorld(x, y) && currentGeneration[x][y];
} |
c4a629af-3fc2-4df0-b53c-79b2f038e6e2 | @Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(Color.white);
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setColor(Color.black);
for (int x = 0; x < gridWidth; x++) {
for (int y = 0; y < gridHeight; y++) {
if (!isAlive(x, y))
... |
24dc7894-29b9-4800-8140-5d2c6e6a3e8b | public void fillRandomly() {
for (int x = 0; x < gridWidth; x++) {
for (int y = 0; y < gridHeight; y++) {
currentGeneration[x][y] = random.nextBoolean();
}
}
repaint();
} |
b035fd88-467c-48e0-8e97-26203cc547ea | public void tick() {
for (int x = 0; x < gridWidth; x++) {
for (int y = 0; y < gridHeight; y++) {
tickCell(x, y);
}
}
nextGeneration();
repaint();
} |
7a59aab0-f4ef-419e-8e3e-2cc1c669021d | private void tickCell(int x, int y) {
int livingNeighbors = countLivingNeighbors(x, y);
if (isAlive(x, y)) {
if (livingNeighbors < 2 || livingNeighbors > 3) {
nextGeneration[x][y] = false;
}
}
else {
if (livingNeighbors == 3) {
nextGeneration[x][y] = true;
}
... |
9bae598c-04b2-426a-8684-10361da6b53a | private int countLivingNeighbors(int x, int y) {
int livingNeighbors = 0;
for (int xx = x - 1; xx < x + 2; xx++) {
for (int yy = y - 1; yy < y + 2; yy++) {
if (xx == x && yy == y)
continue;
if (isAlive(xx, yy)) {
livingNeighbors++;
}
}
}
return ... |
3d8536ab-4509-4bfb-84f9-e871fd94c016 | private void nextGeneration() {
for (int x = 0; x < gridWidth; x++) {
for (int y = 0; y < gridHeight; y++) {
currentGeneration[x][y] = nextGeneration[x][y];
}
}
} |
7d1f6407-0d5c-414e-a039-8ac5745a9a9c | public static void main(String[] args) {
Deck deck = new Deck();
log.info("cardinfo.Deck size is: " + deck.getDeck().size());
deck.shuffle();
log.info("Shuffled the deck!");
deck.dealAllCards();
try {
deck.dealOneCard(); //deal one more card when deck is empty... |
2aea6341-35c4-4e40-8b3f-00a324e0de9a | public List<Card> getCardList(){
ArrayList<Card> cardList = new ArrayList<Card>();
Field[] fields = this.getClass().getDeclaredFields();
for (Field field : fields) {
if (Card.class.isAssignableFrom(field.getType())){ //alow subclasses of classes implementing CardDeck too
... |
7dc8ed7a-36f7-4be5-ba5d-c907160ed152 | Suit(String text){
this.mText = text;
} |
ef1b1090-06a1-4380-a5c7-cf159c742eee | @Override
public String toString() {
return this.mText;
} |
f286b9b9-374e-4a9e-9d8a-359a2c9ca28d | public Deck() {
for (Suit suit : Suit.values()) {
for (Value value : Value.values()) {
deck.push(
new Card(value, suit)
);
}
}
} |
7e1647ce-c406-4a0e-b6c1-028ca638a76c | public Deck(List<Card> cards) throws IllegalArgumentException {
constructDeckFromList(cards);
} |
d0cbae81-9c35-413d-af69-548d84a18ced | public Deck(CardDeck cardDeck) throws IllegalArgumentException {
constructDeckFromList(
cardDeck.getCardList()
);
} |
c2e090e5-781b-4034-be33-beab95f1095a | private void constructDeckFromList(List<Card> cards){
if (cards != null)
for(Card card : cards)
deck.push(card);
else
throw new IllegalArgumentException("Null list was used to try and construct this deck");
} |
9a4f8c27-1f23-4bbb-94ea-3bc44d545f65 | public void shuffle(){
Random rand = new Random();
for (int i = deck.size() - 1; i > 0; i--){
//randomly generate K
int k = rand.nextInt(i + 1);
//swap card at index 'k' with card at index 'i'
Card x = deck.get(k);
deck.set(k, deck.get(i));
... |
75316d8f-a57f-4536-a48d-4e12f7e00c71 | public Card dealOneCard() throws IllegalStateException {
if (deck != null && deck.size() !=0) {
Card dealtCard = deck.pop();
log.info("dealt card: " + dealtCard);
return dealtCard;
}
else
throw new IllegalStateException("The deck is empty");
} |
ae2f76ea-f1f3-4849-93bf-3639d9feb547 | public void dealAllCards(){
while(deck.size() != 0){
dealOneCard();
}
} |
572a41c3-11ea-405f-a1c2-d0da89ab30a4 | public Stack<Card> getDeck() {
return deck;
} |
a5906492-47df-4095-8f82-8b033a48e68e | @Override
public boolean equals(Object other) {
if (other == null) return false;
if (other == this) return true;
if (!(other instanceof Deck)) return false;
Stack<Card> otherDeck = ((Deck) other).getDeck();
int i = 0;
for (Card otherCard : otherDeck){
Car... |
32980994-3a33-4487-99cd-f54133e92bc6 | Value(int value, String text) {
this.mValue = value;
this.mText = text;
} |
17be9219-cb4e-4cde-8094-90fc03766160 | public int getValue() {
return mValue;
} |
268653f2-3d33-43bb-9f25-fc6c8d4c2bf8 | public String getText() {
return mText;
} |
0c5efc8b-f47a-4c28-a686-06116e76a46c | @Override
public String toString() {
return this.mText;
} |
260d466d-d8fe-4b22-a894-5c55244ef80e | public Card(Value value, Suit suit) {
this.mSuit = suit;
this.mValue = value;
log.info("Added " + this + " to deck.");
} |
66fd3e1a-e0c0-47f3-8cf0-fcab02805051 | @Override
public String toString() {
return getName(this);
} |
5e3a0056-59c0-4b41-a75d-6a67e5870882 | private String getName(Card card){
return card.mValue + " of " + card.mSuit;
} |
336f18d6-3f74-4a62-906a-aa56e589efec | public Suit getmSuit() {
return mSuit;
} |
6cb43d59-248d-4360-bc36-f92701143f0b | public Value getmValue() {
return mValue;
} |
8412c0ce-a296-4d14-8cf1-55c08d18f8e2 | @Override
public int compareTo(Card o) {
int o1 = this.mValue.getValue();
int o2 = o.mValue.getValue();
if (o1 > o2 )
return 1;
else if (o1 < o2)
return -1;
else //numbers are equal
return 0;
} |
901a3d10-3539-4c0d-8267-bb71afbb7bbf | @Override
public boolean equals(Object other) {
if (other == null) return false;
if (other == this) return true;
if (!(other instanceof Card)) return false;
Card otherCard = (Card) other;
if (this.mSuit.equals(otherCard.mSuit) &&
this.mValue.equals(otherCard.... |
f32c9aad-fd90-4334-9cfb-507fe2486600 | @Override
public int hashCode() {
return new HashCodeBuilder(17, 31). // two randomly chosen prime numbers
append(mSuit).
append(mValue).
toHashCode();
} |
f751ffda-0ea6-4685-b75f-30c855c0bd5a | @DataPoints
public static Deck[] decks() {
return new Deck[]{
new Deck(),
new Deck(new CompleteDeck().getCardList()),
new Deck(new EmptyDeck().getCardList())
};
} |
d2faac59-de94-45e2-8ada-bc90e5d8c879 | @Test
public void testDealOneCardWithDefaultDeck() throws Exception {
Deck deck = new Deck();
Card expectedFirstCard = getExpectedTopCardFromFreshDefaultDeck();
Card actualFirstCard = deck.dealOneCard();
Assert.assertEquals(expectedFirstCard, actualFirstCard);
} |
9ea6bc0c-8506-4f62-9b34-bf968a593aa7 | @Test
public void testDealOneCardWithCustomDeck() throws Exception {
List<Card> cards = new CompleteDeck().getCardList();
Deck customDeck = new Deck(cards);
Card expectedFirstCard = getExpectedTopCardFromFreshCustomDeck(cards);
Card actualFirstCard = customDeck.dealOneCard();
... |
3a26759d-7205-4aab-bef1-ca8e03d7ca45 | @Theory
public void testDealAllCards(Deck deck) throws Exception {
deck.dealAllCards();
assert (deck.getDeck().size() == 0); //ensure deck is now empty
} |
adb5ff5b-140d-413e-85c7-0d10699c1eb0 | @Theory
public void testDealOneCardWhenDeckEmpty(Deck deck) throws Exception {
deck.dealAllCards();
try {
deck.dealOneCard(); //trigger deck is empty exception
assert false; //deck is empty exception did not occur
} catch (IllegalStateException e) {
assert... |
af65f513-6bfd-4196-a5e4-308799f3f1a2 | @Test(expected=IllegalArgumentException.class)
public void testExceptionWhenNullListIsUsedToCreateCardDeck() throws Exception {
List<Card> cards= null;
new Deck(cards);
} |
6f6a04e5-687f-446f-a76b-f8c2577617b2 | @Test
public void testDeckSizeWithDefaultDeck() throws Exception {
Deck deck = new Deck();
int actualSize = deck.getDeck().size();
int expectedSize = mValueSize * mSuitSize;
assert (actualSize == expectedSize);
} |
9ecfff9b-5a54-4d6b-a777-b422f2f8833f | @Test
public void testDeckSizeWithCustomDeck() throws Exception {
Deck deck = new Deck(new CompleteDeck());
int actualSize = deck.getDeck().size();
int expectedSize = (CompleteDeck.class.getDeclaredFields()).length;
assert (actualSize == expectedSize);
} |
44b81d3f-6476-4ee1-b12b-091d082b9cc6 | @Test
public void testEqualsAndShuffle() throws Exception {
//TODO improve this method by implementing clonable interface in Deck so we can parameterize
Deck deck1 = new Deck();
Deck deck2 = new Deck();
assertEqualsAndShuffle(deck1, deck2);
deck1 = new Deck(mCardsFull);
... |
ef886f1a-4dd7-4c38-9c48-1e2c1a5041b8 | static private void assertEqualsAndShuffle(Deck deck1, Deck deck2){
Assert.assertEquals(deck1, deck2); //check that they're equal before shuffle.
deck2.shuffle();
Assert.assertNotEquals(deck1, deck2); //check that they're now no longer equal after shuffling
} |
8e5c0254-4525-474f-b7ca-44b752ec7fcd | @Test
public void testEmptyDeckShuffleDeck() throws Exception {
Deck deck = new Deck(mCardsEmpty);
deck.shuffle(); //test that empty deck does not throw error
} |
f6894bfa-99c5-46ad-ace0-d635beb7bfd4 | private Card getExpectedTopCardFromFreshDefaultDeck(){
/**
* To add the cards to the deck, we loop the each of the suits,
* and nested inside there we loop through each of the values to add cards to the deck.
* So, the top card of a fresh deck will be the last declared enum field for ... |
4105c7d0-2814-4e7e-84e1-c9748abd6847 | private Card getExpectedTopCardFromFreshCustomDeck(List<Card> cards){
return cards.get(cards.size() - 1);
} |
3e4a293e-1707-461a-8c1f-b7c5471e55b0 | public ThemeAdapter(Activity context) {
super(context, loadThemes(context), true);
} |
c7a4fa00-0139-44cd-b2bb-e31b420a86d1 | private static Cursor loadThemes(Activity context) {
return context.managedQuery(ThemeColumns.CONTENT_PLURAL_URI,
null, null, ThemeColumns.NAME);
} |
f39c93a9-4d97-4394-bd47-599616b40627 | @Override
protected ThemeItem getCurrentlyAppliedItem(Context context) {
return ThemeItem.getInstance(Themes.getAppliedTheme(context));
} |
aca1469b-00bc-4152-8488-28a88fd6b880 | @Override
protected void onAllocInternal(Cursor c) {
mDAOItem = new ThemeItem(c);
} |
ec46e255-1d82-4b57-a1c5-70697fd0cdb1 | public ThemeItem getTheme(int position) {
return getDAOItem(position);
} |
7ed67f70-f92c-49a1-9ade-2435843571b8 | public int findItem(CustomTheme theme) {
if (theme == null) return -1;
int n = getCount();
while (n-- > 0) {
ThemeItem item = getDAOItem(n);
if (item.equals(theme) == true) {
return n;
}
}
return -1;
} |
a193cdba-0ecd-4a20-8664-5b10d6c91979 | @Override
public ThemeItem init(Cursor c) {
return new ThemeItem(c);
} |
7aa99129-c12b-48e8-81c6-a621fe9f4e12 | public static ThemeItem getInstance(Context context, Uri uri) {
return CREATOR.newInstance(context, uri);
} |
3a1eeab7-54b7-4efb-8256-7e9a7a66dfa7 | public static ThemeItem getInstance(Cursor c) {
return CREATOR.newInstance(c);
} |
0b7f0773-01df-48ed-858f-724d0dd996cf | public ThemeItem(Cursor c) {
super(c);
mColumnId = c.getColumnIndex(ThemeColumns._ID);
mColumnThemeId = c.getColumnIndex(ThemeColumns.THEME_ID);
mColumnThemePackage = c.getColumnIndex(ThemeColumns.THEME_PACKAGE);
mColumnName = c.getColumnIndex(ThemeColumns.NAME);
mColumnS... |
dd63cf0b-e983-4ca6-ba6a-bbff963c8694 | public long getId() {
return mCursor.getLong(mColumnId);
} |
66eaf738-df6c-4562-a2c5-a16f273c99c4 | @Override
public Uri getUri(Context context) {
return Themes.getThemeUri(context, getPackageName(), getThemeId());
} |
bdff8996-1cfc-4ed7-9181-f01fd02dce99 | public String getName() {
return mCursor.getString(mColumnName);
} |
f2d058cd-9247-449e-93ff-73e2d38765d0 | public String getStyleName() {
return mCursor.getString(mColumnStyleName);
} |
a6a512cf-e454-4b0b-b451-937816360924 | public String getAuthor() {
return mCursor.getString(mColumnAuthor);
} |
c036cdfc-dbb5-4f49-bb3c-be3d36e0d44c | public boolean isDRMProtected() {
return mCursor.getInt(mColumnIsDRM) != 0;
} |
2204b6dd-e25d-409a-ab97-487d47feb18c | public String getThemeId() {
return mCursor.getString(mColumnThemeId);
} |
c5054f5a-d1d7-463e-ae05-2020526d774a | public String getPackageName() {
return mCursor.getString(mColumnThemePackage);
} |
0d7a6d14-d35f-49b2-a82d-ffd319b9caa3 | public String getWallpaperIdentifier() {
return mCursor.getString(mColumnWallpaperName);
} |
43cc8efb-32f9-4e33-a463-e2076e62fdb0 | public Uri getWallpaperUri(Context context) {
return parseUriNullSafe(mCursor.getString(mColumnWallpaperUri));
} |
d23bd7b7-ef4f-4ce5-a298-9357cd7b0da2 | public Uri getLockWallpaperUri(Context context) {
return parseUriNullSafe(mCursor.getString(mColumnLockWallpaperUri));
} |
8f85987b-392e-478a-a697-6d26ed43a603 | public Uri getRingtoneUri(Context context) {
return parseUriNullSafe(mCursor.getString(mColumnRingtoneUri));
} |
1377bad9-d3df-4456-8224-dbeb5f2f045c | public String getRingtoneName() {
return mCursor.getString(mColumnRingtoneName);
} |
6b5a4e73-3c7d-44d5-8393-ac4e56a14d30 | public Uri getNotificationRingtoneUri(Context context) {
return parseUriNullSafe(mCursor.getString(mColumnNotifRingtoneUri));
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.