blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cfce9f40e1a976d30b1785a8e85bd17dbd5210e5 | 7dee69299613d22247d203c20d491c35db91edd8 | /Projektaktuell3/Projektaktuell2/Projektaktuell2/Projektaktuell/Projekt01/Messstation.java | 53735d3f5096dbbe8c3c21fcbc88dddcf44656ac | [] | no_license | himarei/Feinstaub-App | d0e58a80b1d783ee9383c0210002645cfc3f2040 | 05fe7dddbbb6c59c21ad7668838b711856caae8e | refs/heads/main | 2023-06-16T04:06:36.326111 | 2021-07-14T07:30:01 | 2021-07-14T07:30:01 | 348,626,384 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 450 | java | import java.util.ArrayList;
import java.util.List;
public class Messstation
{
ArrayList<Messreihe> vieleMessreihen;
String senseBoxId;
public Messstation(String senseBoxId_)
{ senseBoxId = senseBoxId_;
vieleMessreihen = new ArrayList<Messreihe>();
OpenSenseMap oSM = new OpenSenseMap(senseBoxId, vieleMessreihen);
oSM.nameEinlesen();
oSM.sensorenEinlesen();
}
}
| [
"[email protected]"
] | |
1916f0f4fd3ffc0fcbaa4ae0f5b189db8ee300b1 | 42fbb04b57f67682ec607f4e95ea59ce1ad287db | /src/test/java/org/learning/pages/BasePage.java | a4b00821cb680a1d397771c40303f71e46f40db5 | [] | no_license | Dileep17/Webdriver-Spring-Junit5 | 51fb1237f9b16f329d4e6ddbaee78b3717bf0be4 | 762a7cd2263d68c960444d6661d6a2fe4f34ac59 | refs/heads/main | 2023-02-23T09:11:53.019790 | 2021-01-25T11:24:04 | 2021-01-25T11:24:04 | 331,837,088 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,275 | java | package org.learning.pages;
import org.learning.config.Constants;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.PostConstruct;
public class BasePage {
@Autowired
WebDriver driver;
WebDriverWait webDriverWait;
@PostConstruct
public void setUp(){
PageFactory.initElements(driver, this);
webDriverWait = new WebDriverWait(driver, Constants.WEBDRIVER_WAIT_IN_SECONDS);
}
public void waitForElementToBeVisible(WebElement element) {
webDriverWait.until(ExpectedConditions.visibilityOf(element));
}
public void waitForElementToBeClickable(WebElement element) {
waitForElementToBeVisible(element);
webDriverWait.until(ExpectedConditions.elementToBeClickable(element));
}
public void waitForTextToBeDisplayed(String textToBeDisplayed){
webDriverWait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[contains(text(), '" + textToBeDisplayed+ "')]")));
}
}
| [
"[email protected]"
] | |
205d45cb48cc548f9b9bb2a8e854fe9e65a2151e | a53f0e7255c96a203cbd4e33087d792c2bc502fc | /src/main/java/com/zbook/manage/service/BookService.java | ddb429170f0e6cc5819ce450e103878559cbdde2 | [] | no_license | bbsyaya/snail-server | eb8bd842434372b4dd7889ddf95e779654ffdacb | f55ec24e3948f0ddb373bff1f22eeccafb54035a | refs/heads/master | 2021-04-15T07:21:50.575715 | 2017-01-25T09:12:32 | 2017-01-25T09:12:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 396 | java | package com.zbook.manage.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zbook.manage.domain.Book;
import com.zbook.manage.mapper.BookMapper;
@Service
public class BookService {
@Autowired
BookMapper bookMapper;
public List<Book> getBooks() {
return bookMapper.getBooks();
}
}
| [
"[email protected]"
] | |
d568882910fcda742657a2ab4219747b5c0369b8 | ced700b5f6efbe1b716437f530c552a749788565 | /src/main/java/dfa/InitialStep.java | 1af15c34a7548df0532a01135c1f8fe27494ba50 | [] | no_license | Fagam32/DFA-2 | 69b020e96da80d5f1bcb0a8eb52ae0b550f9a0b9 | 8b1a278d74d8a7c24b4e049a34e7450eb711c5cf | refs/heads/master | 2023-01-29T04:48:38.820777 | 2020-12-10T08:16:06 | 2020-12-10T08:16:06 | 320,204,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,185 | java | package dfa;
import java.util.Objects;
public class InitialStep {
int state;
String symbol;
String stackSymbol;
public InitialStep(int state, String symbol, String stackSymbol) {
this.state = state;
this.symbol = symbol;
this.stackSymbol = stackSymbol;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public String getStackSymbol() {
return stackSymbol;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
InitialStep that = (InitialStep) o;
return state == that.state && Objects.equals(symbol, that.symbol) && Objects.equals(stackSymbol, that.stackSymbol);
}
@Override
public int hashCode() {
return Objects.hash(state, symbol, stackSymbol);
}
public void setStackSymbol(String stackSymbol) {
this.stackSymbol = stackSymbol;
}
}
| [
"[email protected]"
] | |
442991c8cd96a58456773ddfc1a80c8956771724 | 1225a8999a66d4662ec5e7f700367ba4d82671b7 | /Core/src/Lesson4/LeftSiderBarBody.java | ba615e999ebaa773e374e8cc311f7389e8d0782a | [] | no_license | Mariia679/AllProjects | 7fe377d0bd0f66707bf9041caeecb772d95df5ad | 77371b369a45fbaacf9b7b3793c259b5f394ba9f | refs/heads/master | 2021-01-21T10:33:54.276205 | 2017-02-28T15:42:46 | 2017-02-28T15:42:46 | 83,449,942 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 653 | java | package Lesson4;
public class LeftSiderBarBody implements Body{
@Override
public void printBody() {
System.out.println("|------|-----------------|");
System.out.println("| | |");
System.out.println("| | |");
System.out.println("| LEFT | |");
System.out.println("| SIDE | BODY |");
System.out.println("| BAR | |");
System.out.println("| | |");
System.out.println("| | |");
System.out.println("| | |");
System.out.println("|------|-----------------|");
}
}
| [
"[email protected]"
] | |
6cdaaa9fded38715287d891dc81ed179ffeb5d9f | f539bfda3a620f76177f7812391d6d25df26f47b | /AppCode/src/main/java/gov/cdc/epiinfo/statcalc/etc/Ref.java | 1168c7f5c97614b3baa7bb4e56f37b70a35eb6b4 | [
"Apache-2.0"
] | permissive | Epi-Info/Epi-Info-Android | c5f8efb8c6434249a46cf50fd82d935ca6035d19 | e293bbc204c29bff591c5df164361724750ae45a | refs/heads/master | 2023-09-01T03:08:18.344846 | 2023-08-21T20:37:19 | 2023-08-21T20:37:19 | 112,626,339 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 454 | java | package gov.cdc.epiinfo.statcalc.etc;
public class Ref<T> {
private T value;
public Ref(T value)
{
this.value = value;
}
public T get()
{
return value;
}
public void set(T value)
{
this.value = value;
}
@Override
public String toString()
{
return value.toString();
}
@Override
public boolean equals(Object obj)
{
return value.equals(obj);
}
@Override
public int hashCode()
{
return value.hashCode();
}
}
| [
"[email protected]"
] | |
f2341c6003f09123f80a43c0d486064868b93f7c | 1eac4ff024ca4210680e429db61975a0a6daf549 | /model/swing/SwingAnimatorBuilder.java | 0c4954dbdc757b728584a1fc44b973e451f21f8e | [] | no_license | terryschmidt/TrafficSimulation | 3851e4d141d5ace5eec2da0c2247fe5237dc99e3 | b5210697443bd2ef6272ada516c783756620b3e4 | refs/heads/master | 2020-12-31T00:18:08.491752 | 2015-11-25T06:58:34 | 2015-11-25T06:58:34 | 46,843,523 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,819 | java | package myproject.model.swing;
import java.awt.Color;
import java.awt.Graphics;
import java.util.ArrayList;
import java.util.List;
import myproject.model.AnimatorBuilder;
import myproject.model.Car;
import myproject.model.Light;
import myproject.model.MP;
import myproject.model.Road;
import myproject.util.Animator;
import myproject.util.SwingAnimator;
import myproject.util.SwingAnimatorPainter;
/**
* A class for building Animators.
*/
public class SwingAnimatorBuilder implements AnimatorBuilder {
MyPainter painter;
public SwingAnimatorBuilder() {
painter = new MyPainter();
}
public Animator getAnimator() {
if (painter == null) { throw new IllegalStateException(); }
Animator returnValue = new SwingAnimator(painter, "Traffic Simulator",
VP.displayWidth, VP.displayHeight, VP.displayDelay);
painter = null;
return returnValue;
}
private static double skipInit = VP.gap;
private static double skipRoad = VP.gap + MP.roadLength;
private static double skipCar = VP.gap + VP.elementWidth;
private static double skipRoadCar = skipRoad + skipCar;
public void addLight(Light d, int i, int j) {
double x = skipInit + skipRoad + j*skipRoadCar;
double y = skipInit + skipRoad + i*skipRoadCar;
Translator t = new TranslatorWE(x, y, MP.carLength, VP.elementWidth, VP.scaleFactor);
painter.addLight(d,t);
}
public void addHorizontalRoad(Road l, int i, int j, boolean eastToWest) {
double x = skipInit + j*skipRoadCar;
double y = skipInit + skipRoad + i*skipRoadCar;
Translator t = eastToWest ? new TranslatorEW(x, y, MP.roadLength, VP.elementWidth, VP.scaleFactor)
: new TranslatorWE(x, y, MP.roadLength, VP.elementWidth, VP.scaleFactor);
painter.addRoad(l,t);
}
public void addVerticalRoad(Road l, int i, int j, boolean southToNorth) {
double x = skipInit + skipRoad + j*skipRoadCar;
double y = skipInit + i*skipRoadCar;
Translator t = southToNorth ? new TranslatorSN(x, y, MP.roadLength, VP.elementWidth, VP.scaleFactor)
: new TranslatorNS(x, y, MP.roadLength, VP.elementWidth, VP.scaleFactor);
painter.addRoad(l,t);
}
/** Class for drawing the Model. */
private static class MyPainter implements SwingAnimatorPainter {
/** Pair of a model element <code>x</code> and a translator <code>t</code>. */
private static class Element<T> {
T x;
Translator t;
Element(T x, Translator t) {
this.x = x;
this.t = t;
}
}
private List<Element<Road>> roadElements;
private List<Element<Light>> lightElements;
MyPainter() {
roadElements = new ArrayList<Element<Road>>();
lightElements = new ArrayList<Element<Light>>();
}
void addLight(Light x, Translator t) {
lightElements.add(new Element<Light>(x,t));
}
void addRoad(Road x, Translator t) {
roadElements.add(new Element<Road>(x,t));
}
public void paint(Graphics g) {
// This method is called by the swing thread, so may be called
// at any time during execution...
// First draw the background elements
for (Element<Light> e : lightElements) {
/*if (e.x.getState()) {
g.setColor(Color.BLUE);
} else {
g.setColor(Color.YELLOW);
}
XGraphics.fillOval(g, e.t, 0, 0, MP.carLength, VP.elementWidth);*/
g.setColor(e.x.getCurrentColor());
XGraphics.fillRect(g, e.t, 0, 0, MP.carLength, VP.elementWidth);
}
g.setColor(Color.BLACK);
for (Element<Road> e : roadElements) {
XGraphics.fillRect(g, e.t, 0, 0, MP.roadLength, VP.elementWidth);
}
// Then draw the foreground elements
for (Element<Road> e : roadElements) {
// iterate through a copy because e.x.getCars() may change during iteration...
for (Car d : e.x.getAllCars().toArray(new Car[0])) {
g.setColor(d.getColor());
XGraphics.fillOval(g, e.t, d.getPosition(), 0, MP.carLength, VP.elementWidth);
}
}
}
}
}
| [
"[email protected]"
] | |
bb3e61cdc59c4ca8e27f42cc92402f0a30e9f40c | ca957060b411c88be41dfbf5dffa1fea2744f4a5 | /src/org/sosy_lab/cpachecker/appengine/io/GAEPathTest.java | 2dad37d12f2a1fe26c6f994270437824e7e609f4 | [
"Apache-2.0"
] | permissive | 45258E9F/IntPTI | 62f705f539038f9457c818d515c81bf4621d7c85 | e5dda55aafa2da3d977a9a62ad0857746dae3fe1 | refs/heads/master | 2020-12-30T14:34:30.174963 | 2018-06-01T07:32:07 | 2018-06-01T07:32:07 | 91,068,091 | 4 | 6 | null | null | null | null | UTF-8 | Java | false | false | 4,334 | java | /*
* CPAchecker is a tool for configurable software verification.
* This file is part of CPAchecker.
*
* Copyright (C) 2007-2014 Dirk Beyer
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* CPAchecker web page:
* http://cpachecker.sosy-lab.org
*/
package org.sosy_lab.cpachecker.appengine.io;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.io.FileWriteMode;
import org.junit.Test;
import org.sosy_lab.common.io.Path;
import org.sosy_lab.cpachecker.appengine.common.DatastoreTest;
import org.sosy_lab.cpachecker.appengine.dao.TaskDAO;
import org.sosy_lab.cpachecker.appengine.dao.TaskFileDAO;
import org.sosy_lab.cpachecker.appengine.entity.Task;
import org.sosy_lab.cpachecker.appengine.entity.TaskFile;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
public class GAEPathTest extends DatastoreTest {
private Task task;
private TaskFile file;
private Path path;
@Override
public void setUp() {
super.setUp();
task = new Task(1L);
file = new TaskFile("test.tmp", task);
file.setContent("lorem ipsum dolor sit amet");
try {
TaskFileDAO.save(file);
} catch (IOException e) {
fail(e.getMessage());
}
TaskDAO.save(task);
path = new GAEPath("test.tmp", task);
}
@Test
public void shouldDeleteFile() throws Exception {
path.delete();
assertNull(TaskFileDAO.loadByName("test.tmp", task));
}
@Test
public void shouldReturnWorkingByteSource() throws Exception {
try (InputStream in = path.asByteSource().openStream();
ByteArrayOutputStream out = new ByteArrayOutputStream()) {
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
assertEquals(file.getContent(), out.toString());
}
}
@Test
public void shouldReturnWorkingCharSource() throws Exception {
try (Reader reader = path.asCharSource(null).openStream();
StringWriter w = new StringWriter()) {
int c;
while ((c = reader.read()) != -1) {
w.write(c);
}
assertEquals(file.getContent(), w.toString());
}
}
@Test
public void shouldReturnWorkingByteSink() throws Exception {
try (OutputStream out = path.asByteSink().openStream()) {
out.write(new String("test").getBytes());
}
assertEquals("test", file.getContent());
}
@Test
public void shouldReturnWorkingCharSink() throws Exception {
try (Writer writer = path.asCharSink(Charset.defaultCharset()).openStream()) {
writer.write("test");
}
assertEquals("test", file.getContent());
}
@Test
public void shouldAppendWithByteSink() throws Exception {
String oldContent = file.getContent();
try (OutputStream out = path.asByteSink(FileWriteMode.APPEND).openStream()) {
out.write(new String("test").getBytes());
}
assertEquals(oldContent + "test", file.getContent());
}
@Test
public void shouldAppendWithCharSink() throws Exception {
String oldContent = file.getContent();
try (Writer writer = path.asCharSink(Charset.defaultCharset(), FileWriteMode.APPEND)
.openStream()) {
writer.write("test");
}
assertEquals(oldContent + "test", file.getContent());
}
@Test
public void shouldBeFile() throws Exception {
Path path = new GAEPath("foo.bar", task);
assertTrue(path.isFile());
}
@Test
public void shouldNotBeFile() throws Exception {
Path path = new GAEPath("foo", task);
assertFalse(path.isFile());
}
}
| [
"[email protected]"
] | |
10b9068d9beefb1a44e9b6d4e30de30d092ccfd0 | b199e23f0b2e1e435c8dbae00eb07dca691089f4 | /rabbitmq-api/src/main/java/com/yibo/rabbitmq/limit/MyConsumer.java | d080116003be5eccda2199dbf6d34ada152d259e | [] | no_license | jjhyb/rabbitmq-study | 4c6ebcf885805fc5ade6a43dca6274dc5874215d | 1d7d045b73312f512be53fca384b8bea1073db75 | refs/heads/master | 2020-09-27T07:55:57.989106 | 2019-12-07T06:51:38 | 2019-12-07T06:51:38 | 226,469,064 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 838 | java | package com.yibo.rabbitmq.limit;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import java.io.IOException;
/**
* @author: huangyibo
* @Date: 2019/12/3 18:33
* @Description:
*/
public class MyConsumer extends DefaultConsumer {
private Channel channel;
public MyConsumer(Channel channel) {
super(channel);
this.channel = channel;
}
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
String message = new String(body, "UTF-8");
System.out.println(envelope.getRoutingKey() + ":" + message);
//手动签收
channel.basicAck(envelope.getDeliveryTag(),false);
}
}
| [
"[email protected]"
] | |
1a784361864941dce2dc06fb6b0469dd2a83db1b | 6d4aa7c858fe0bf1737cd3f11de6a0d9de25c20f | /02-java-oop/07-bank-account/BankAccount.java | 6f6cd4ab654be7150670637fdc5087c7b3d572d3 | [] | no_license | Java-May-2021/EvgheniaR-Assigments | 5a5b53dda43a47508580906510aac2d4270974ba | 187bbc9d75b1ca7ff9224cb59e34911390d2e977 | refs/heads/master | 2023-05-30T22:07:41.514787 | 2021-06-25T23:57:11 | 2021-06-25T23:57:11 | 364,072,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,686 | java | import java.util.Random;
public class BankAccount{
private String accountNumber;
private double checkingAccount;
private double savingsAccount;
public static int numberOfAccounts = 0;
public static double totalAmount = 0;
private static String ReturnsRandomNumbers(){
String num = "";
Random r = new Random();
for(int i=0; i<=10;i++);{
num += r.nextInt(10);
}
return num;
}
public BankAccount(){
this.accountNumber = BankAccount.ReturnsRandomNumbers();
this.checkingAccount = 0;
this.savingsAccount = 0;
BankAccount.numberOfAccounts++;
System.out.println("Checking account is:"+ this.checkingAccount);
System.out.println("Savings account is:" + this.savingsAccount);
}
public double getUserCheckingAccountBal(){
System.out.printf("Checking Account balance is:$%.2f\n",this.checkingAccount);
return this.checkingAccount;
}
public double getUserSavingAccountBal(){
System.out.printf("Saving Account balance is:$%.2f\n",this.savingsAccount);
return this.savingsAccount;
}
public void deposit(String account,double amount ){
if(account.equals("checking")){
this.checkingAccount += amount;
System.out.printf("Deposit to checking: $%.2f \n", amount);
}else if(account.equals("saving")){
this.savingsAccount += amount;
System.out.printf("Desposit to savings:$%.2f \n", amount);
BankAccount.totalAmount += amount;
}
}
public void withdraw(String account,double amount){
boolean sufficientFunds = false;
if(account.equals("saving")){
if(this.savingsAccount>= 0){
sufficientFunds = true;
this.savingsAccount -= amount;
System.out.printf("Savings account now is: $%.2f \n",savingsAccount);
}
}
else if(account.equals("checking")){
if(this.savingsAccount >= 0){
sufficientFunds = true;
this.checkingAccount -= amount;
System.out.printf("Checking account now is: $%.2f \n",checkingAccount);
}
}
if(sufficientFunds){
BankAccount.totalAmount -= amount;
}
}
public void displayAccountBalance(){
System.out.printf("Checking: $%.2f, Saving:$%.2f \n", this.checkingAccount,this.savingsAccount);
}
public static int numberOfAccounts(){
System.out.printf("Total accounts at the moment is: %d", BankAccount.numberOfAccounts);
return BankAccount.numberOfAccounts;
}
} | [
"[email protected]"
] | |
f273e394a368f1ce329f60ccae6d618868ab695f | 1c28be1286e9518def987d57dd8357502efa21dd | /src/ConnectFourPackage/SmartAi.java | 2711f947ae0b991b9441d1865e5c2a1674f6cb36 | [] | no_license | jon-takagi/Connect-4 | aa1b96acea6f825099442ede34203e18745d1935 | 7236661244da3b7803243fd02b249183b147a39e | refs/heads/master | 2021-01-01T06:16:56.912628 | 2015-02-06T07:12:13 | 2015-02-06T07:12:13 | 29,951,230 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,123 | java | package ConnectFourPackage;
import javafx.scene.paint.Color;
import java.util.ArrayList;
/**
* Created by 40095 on 1/24/15.
*/
public class SmartAi extends Connect4Player implements Connect4AI {
ArrayList<Group> winningGroups, losingGroups, zugzwangGroups, winnableGroups, groups;
//Winning groups is all groups that can be won on the next play
//Losing groups is all the groups that will lead to defeat in the next play
//future threats are all groups with three of a kind, but the 4th tile is not playable (Zugzwang)
//winnableGroups is all groups that do not contain the opponents tile
//groups is all groups
/*
Order of precedence for plays to make:
1) plays that make you win immediately
Pick first group from left
2) plays that keep you from losing immediately
Pick first group from left
3) plays that are in a winnable group AND not zugzwang
Pick winnable group with most of your own tokens
4) zugzwang plays
Pick first group from left
*/
public SmartAi() {
// getGroups();
groups = new ArrayList<>(69);
winningGroups = new ArrayList<Group>();
losingGroups = new ArrayList<Group>();
zugzwangGroups = new ArrayList<Group>();
winnableGroups = new ArrayList<>();
}
private void getGroups() {
// Initialize and place the groups
int[] dRows = {-1, 0, 1, 1};
int[] dCols = {1, 1, 1, 0};
int fRow, fCol;
for (int i = 0; i < board.length; i++) {
for (int j = 0; j < board[0].length; j++) {
// start @ i,j
//
// if 0 < i + 3 * dCol <= board[0].length, 0 < j + 3 * dRow <= board.length
// create new group from i,j with specified increment pair
//
// possible directions are: diagonal up, right, diagonal down, down
// / -1 row +1 col
// > 0 row +1 col
// \ +1 row +1 col
// | +1 row 0 col
for (int k = 0; k < dRows.length; k++) {
fRow = i + 3 * dRows[k];
fCol = j + 3 * dCols[k];
// switch (k) {
// case 0:
// System.out.print("/ ");
// break;
// case 1:
// System.out.print("> ");
// break;
// case 2:
// System.out.print("\\ ");
// break;
// case 3:
// System.out.print("| ");
// break;
// }
if (fRow >= 0 && fRow <= board.length - 1 && fCol >= 0 && fCol <= board[0].length - 1) {
// System.out.println("Group: [" + j + "][" + i + "] to [" + fRow + "][" + fCol + "] is possible");
groups.add(new Group(board, i, j, dCols[k], dRows[k]));
}
}
}
}
}
private boolean isPlayable(int row, int col) {
if (row == 5)
return board[row][col].equals(Color.WHITE);
return board[row][col].equals(Color.WHITE) && !board[row + 1][col].equals(Color.WHITE);
}
private int tilesBelowSpace(int row, int col) {
int count = 0;
for (int i = row; i < 5; i++) {
if (board[i][col].equals(Color.WHITE)) {
count++;
}
}
return count;
}
private int winningCol() {
refreshGroups();
if (winnableGroups.size() > 0) {
return winningGroups.get(0).dangerousCol();
}
if (losingGroups.size() > 0) {
return losingGroups.get(0).dangerousCol();
}
return 1;
}
private void setWinningGroups() {
winnableGroups.clear();
for (Group group : groups) {
if (group.dangerousCol() > 0 && group.dangerousRow() > 0) {
if (group.getDangerous() != -1 && group.getCriticalColor().equals(token) && isPlayable(group.dangerousCol(), group.dangerousRow())) {
winningGroups.add(group);
}
}
}
}
private void setLosingGroups() {
losingGroups.clear();
for (Group group : groups) {
if (group.dangerousCol() > 0 && group.dangerousRow() > 0) {
if (group.getDangerous() != -1 && !group.getCriticalColor().equals(token) && isPlayable(group.dangerousCol(), group.dangerousRow())) {
losingGroups.add(group);
}
}
}
}
private void setWinnableGroups() {
for (Group g : groups) {
if (token.equals(Color.RED)) {
if (g.doesNotContain(Color.YELLOW)) {
winnableGroups.add(g);
}
} else {
if (g.doesNotContain(Color.RED)) {
winnableGroups.add(g);
}
}
}
}
private void setZugzwangGroups() {
for (Group g : groups) {
if (!isPlayable(g.dangerousRow(), g.dangerousCol())) //if the group is not playable
zugzwangGroups.add(g);
}
}
private void refreshGroups() {
setWinningGroups();
setLosingGroups();
setWinnableGroups();
setZugzwangGroups();
}
public int makePlay() {
if (winningCol() != -1) {
// System.out.println("Playing critical column");
// if (winningGroups.size() == 0)
// System.out.println("Not on my watch");
// else
// System.out.println("I win!");
return winningCol();
} else {
// System.out.println("playing random");
}
return -1;
}
@Override
public int getMove(Color[][] board, Color me) {
this.token = me;
this.board = board;
getGroups();
return makePlay();
}
} | [
"[email protected]"
] | |
d17d757b94b9aea745fbd558f0b07749ed5fa4fb | 389c294320f3bb9c5929b68f9fa5ccb240a2cd0b | /src/main/java/io/polyglotted/pgmodel/geo/GeoType.java | bf292e3e09b9a2a4738aa9bcb81793a2009630b4 | [
"Apache-2.0"
] | permissive | DevFactory/pg-model | b7b8f1df6a0095a5314392dbfb77539613a8531a | b8a1073e3016e56754ef625873a35f7fefa017e6 | refs/heads/master | 2020-12-30T20:43:58.627199 | 2016-01-22T21:48:11 | 2016-01-22T21:48:11 | 55,445,173 | 0 | 0 | null | 2016-04-04T21:06:25 | 2016-04-04T21:06:24 | Java | UTF-8 | Java | false | false | 181 | java | package io.polyglotted.pgmodel.geo;
@SuppressWarnings("unused")
public enum GeoType {
POINT, LINESTRING, POLYGON, MULTIPOINT, MULTILINESTRING, MULTIPOLYGON, ENVELOPE, CIRCLE
}
| [
"[email protected]"
] | |
73b24e6c4a559a668097af7a3122b04754e7d51a | d4cd965597b10c264a674297c70ece4cf4b1d847 | /HelloWorld.java | 4891dd1ae1998908a8b88e399d4ce88375b6d8be | [] | no_license | 21kataka/Kayu | 6fd04cc002bad4c0f64135831142315901d5e2ce | 3d240e6a5b7b9a71f2d37c5f7b59c73295064490 | refs/heads/master | 2020-12-02T07:50:34.429530 | 2017-07-14T23:20:48 | 2017-07-14T23:20:48 | 96,733,895 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 437 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package hello.world;
/**
*
* @author Education Unlmited
*/
public class HelloWorld {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Hello World");
}
}
| [
"[email protected]"
] | |
6dcd40a9efb725a74a0f31452105016cbf5592a6 | 158f374c380f638947877d46bc2fea123cf5f5f6 | /jdk/test/src/main/java/com/kylin/test/util/concurrent/SemaphoreTest.java | f073e3c40d1fdf4819312ea880b440056b4a7d9b | [] | no_license | rodesad/JVM | c4eca80801601c1cfb34327bbe2e4a0b04ee9d3e | b20daad5c1cd96e9410c7ff718a998677a14c88f | refs/heads/master | 2020-11-30T11:53:59.845028 | 2015-01-07T13:21:47 | 2015-01-07T13:21:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,370 | java | package com.kylin.test.util.concurrent;
import java.util.concurrent.Semaphore;
public class SemaphoreTest {
public static void main(String[] args) throws InterruptedException {
new SemaphoreTest().test();
}
private void test() throws InterruptedException {
Pool pool = new Pool(10);
for(int i = 0 ; i < 15 ; i ++) {
pool.getItem();
}
}
private class Pool {
private int MAX_AVAILABLE = 0;
private Semaphore available ;
public Pool(int size){
this.MAX_AVAILABLE = size;
available = new Semaphore(MAX_AVAILABLE, true);
}
public Object getItem() throws InterruptedException{
available.acquire();
return getNextAvailableItem();
}
public void putItem(Object x) {
if (markAsUnused(x)){
available.release();
}
}
protected Object[] items = new Object[MAX_AVAILABLE];
protected boolean[] used = new boolean[MAX_AVAILABLE];
protected synchronized boolean markAsUnused(Object item) {
for (int i = 0; i < MAX_AVAILABLE; i++){
if (item == items[i]){
if (used[i]){
used[i] = false;
return true;
} else {
return false;
}
}
}
return false;
}
protected synchronized Object getNextAvailableItem() {
for (int i = 0; i < MAX_AVAILABLE; i++){
if (!used[i]) {
used[i] = true;
return items[i];
}
}
return null;
}
}
}
| [
"[email protected]"
] | |
47f09735da0f19a90c244280621ed9370fba150b | 03bcc109513fbef6ab73a11f0fbbc5a3e456be80 | /src/fr/craftyourmind/launcher/control/LauncherController.java | 9e7e7a45641d4bf4711c0f8cbc6fbba32eec9282 | [] | no_license | 0ctave/CYMLauncher | 9e227f7f74ef6bf6bfc64d6e9c18e922357f014b | 74a4ab48fa1df8b900390fc3c9a07aeaf590fc3b | refs/heads/master | 2022-11-08T17:32:51.405347 | 2020-06-21T16:13:09 | 2020-06-21T16:13:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,027 | java | package fr.craftyourmind.launcher.control;
import fr.craftyourmind.launcher.MainAux;
import fr.craftyourmind.launcher.util.Auth;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import java.net.URL;
import java.util.ResourceBundle;
public class LauncherController implements Initializable {
@FXML
private TextField username;
@FXML
private PasswordField password;
@FXML
private Button facebook;
@FXML
private Button twitter;
@FXML
private Button youtube;
@FXML
private Button settings;
@FXML
private Label invalidCredential;
private MainAux main;
public void initialize(URL url, ResourceBundle resourceBundle) {
main = MainAux.getInstance();
}
@FXML
private void play(ActionEvent actionEvent) throws Exception {
if (this.username.getText().isEmpty() || this.password.getText().isEmpty()) {
main.cancel();
} else {
((Button)actionEvent.getSource()).setDisable(true);
this.settings.setDisable(true);
this.username.setDisable(true);
this.password.setDisable(true);
this.invalidCredential.setVisible(false);
new Auth(this.username.getText(), this.password.getText());
}
}
@FXML
private void social(ActionEvent actionEvent) {
if (actionEvent.getSource() == this.facebook)
main.showDoc("https://www.facebook.com/pages/Craft-Your-Mind/1642931989260122?fref=ts");
if (actionEvent.getSource() == this.twitter)
main.showDoc("https://twitter.com/Craft_Your_Mind");
if (actionEvent.getSource() == this.youtube)
main.showDoc("https://www.youtube.com/channel/UCAAGkWQA5rc2A36HEj839Yw");
}
@FXML
public void settings() {
main.showSettings();
}
} | [
"[email protected]"
] | |
a328d4d533f48460e0d7bd09d031d0c218be0aaa | a7732a9f1eaf52ab714bb17621e88af49c6d02e6 | /version-resolution/src/test/java/org/jboss/set/mavendependencyupdater/rules/QualifierRestrictionTestCase.java | 0a6a41461f6422df9e89b4fcc61f271fe8798e86 | [] | no_license | jboss-set/maven-dependency-updater | b12744419ae2074dcacb4c2436cf8cafc6d1a0d2 | 922f379a53ce152edaf29e62fded4a16d2fc6a97 | refs/heads/master | 2023-08-26T22:43:57.180099 | 2023-07-28T11:25:33 | 2023-07-28T11:25:33 | 196,525,726 | 1 | 4 | null | 2023-08-15T17:45:08 | 2019-07-12T06:56:26 | Java | UTF-8 | Java | false | false | 1,220 | java | package org.jboss.set.mavendependencyupdater.rules;
import org.junit.Assert;
import org.junit.Test;
public class QualifierRestrictionTestCase {
@Test
public void test() {
String[] regexprs = {
"Final",
"Final-redhat-\\d+"
};
QualifierRestriction restriction = new QualifierRestriction(regexprs);
Assert.assertTrue(restriction.applies("1.2.3.Final"));
Assert.assertTrue(restriction.applies("1.Final"));
Assert.assertTrue(restriction.applies("1.Final-redhat-00001"));
Assert.assertFalse(restriction.applies("1.Final-jboss-00001"));
Assert.assertFalse(restriction.applies("1.F"));
Assert.assertFalse(restriction.applies("1.2"));
}
@Test
public void testEmptyQualifier() {
String[] regexprs = {
"",
"Final"
};
QualifierRestriction restriction = new QualifierRestriction(regexprs);
Assert.assertTrue(restriction.applies("1.2.3.Final"));
Assert.assertTrue(restriction.applies("1.2"));
Assert.assertFalse(restriction.applies("1.Final-redhat-00001"));
Assert.assertFalse(restriction.applies("1.F"));
}
}
| [
"[email protected]"
] | |
709a2584ecac38aa5cb4401dd337439d4c9340ac | 157a2ebcf8bd7a1e2094afa4ef26ed4e607aed2d | /src/main/java/com/saiy/config/WebAppInitializer.java | 8737546a8ab1b9ad8c250288d7a29189af224b55 | [] | no_license | wangpeach/spring-mvc | 378a059f6f04773da2113aa4287c957be683a576 | d01c40cc3168931d5dae821387c402b82159bdd9 | refs/heads/master | 2020-12-03T06:30:26.812693 | 2017-06-28T16:22:19 | 2017-06-28T16:22:19 | 95,688,860 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 945 | java | package com.saiy.config;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
/**
* Created by rjora on 2016/12/29 0029.
*/
public class WebAppInitializer implements WebApplicationInitializer {
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(WebConfig.class);
context.setServletContext(servletContext);
ServletRegistration.Dynamic servlet = servletContext.addServlet("dispatcher", new DispatcherServlet(context));
servlet.setLoadOnStartup(1);
servlet.addMapping("/");
}
}
| [
"213410.ant"
] | 213410.ant |
4344a2b811817a7af5b563f8a12ac3e44429c33e | 7505a5f868c113fe3fdb4f5df776418e6c0f343b | /app/src/main/java/com/example/notes/NoteSourceImp.java | 9cc324a9493205d86cac4b80cdaeeb860c135848 | [] | no_license | Amina1000/Notes | c638935c6c428039b4535674e6aab9c217c12f2c | 012cb319086908f97dcc8a0aead5d4915c4f64e1 | refs/heads/master | 2023-07-14T11:41:00.211363 | 2021-08-15T13:53:27 | 2021-08-15T13:53:27 | 373,951,877 | 0 | 0 | null | 2021-08-15T13:53:28 | 2021-06-04T20:24:16 | Java | UTF-8 | Java | false | false | 1,293 | java | package com.example.notes;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* homework com.example.notes
*
* @author Amina
* 12.06.2021
*/
public class NoteSourceImp implements NoteSource{
private final List <Object> objectListItem;
public NoteSourceImp(List <Object> objectListItem) {
this.objectListItem = objectListItem;
}
public boolean isGroupItem(int position) {
return !(objectListItem.get(position) instanceof Note);
}
public String getGroupTitle(int position) {
Date date = (Date) objectListItem.get(position);
return new SimpleDateFormat("yyyy-MM-dd").format(date);
}
public Note getNoteData(int position) {
return (Note) objectListItem.get(position);
}
public int size(){
return objectListItem.size();
}
@Override
public void deleteNoteData(int position) {
objectListItem.remove(position);
}
@Override
public void updateNoteData(int position, Note noteData) {
objectListItem.set(position, noteData);
}
@Override
public void addNoteData(Note noteData) {
objectListItem.add(noteData);
}
@Override
public void clearNoteData() {
objectListItem.clear();
}
}
| [
"[email protected]"
] | |
5de7e93eeee7806c0cb7e243c38c3c87f0d4e15e | a106437de3120aadbec0de036ef5061cc9096477 | /src/main/GamePanel.java | fb1f41bebc459afe406fee95e684f5a26b55d008 | [] | no_license | dliGH/jar-mania | dee8d02d134cc58088030b7481f7f68830e500b6 | 078dbaa843d12df30c5bdc716d1f5246b65db2c0 | refs/heads/main | 2023-03-01T01:09:04.871807 | 2021-02-07T21:32:45 | 2021-02-07T21:32:45 | 336,893,271 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,647 | java | package main;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
import GameState.GameStateManager;
import java.awt.event.KeyEvent;
import java.awt.event.*;
public class GamePanel extends JPanel implements Runnable, KeyListener{
//creating dimensions
public static final int WIDTH = 320;
public static final int HEIGHT = 240;
public static final int SCALE = 2;
//threads that the gameloop will run on
private Thread thread;
private boolean running;
private int FPS = 60;
private long targetTime = 1000/FPS;
//images
private BufferedImage image;
private Graphics2D g;
//game state manager (allows switching between menu and levels)
private GameStateManager gsm;
public GamePanel() {
//modifying jpanel properties so that it shows in the frame
this.setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
this.setFocusable(true);
this.requestFocus();
}
public void addNotify() {
//let's computer know that game is running
//will start the threads (inbuilt java function to prioritize computing)
super.addNotify();
if(thread == null) {
thread = new Thread(this);
//can do this bc we implemented keylistener
this.addKeyListener(this);
thread.start();
}
}
//initializing method
private void init() {
image = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
g = (Graphics2D) image.getGraphics();
running = true;
gsm = new GameStateManager();
}
public void run() {
init();
//timer variables
long start;
long elapsed;
long wait;
//game loop starts in here
while(running) {
start = System.nanoTime();
update();
draw();
drawToScreen();
elapsed = System.nanoTime() - start;
wait = targetTime - elapsed/1000000;
//was pulling exception so here's something
if(wait<0) {
wait = 5;
}
try {
Thread.sleep(wait);
}
catch(Exception e) {
e.printStackTrace();
}
}
}
//goes from this class to GSM for orgainization
private void update() {
gsm.update();
}
private void draw() {
gsm.draw(g);
}
private void drawToScreen() {
Graphics g2 = getGraphics();
//panel wasn't full screen but fixed it here
g2.drawImage(image, 0, 0, WIDTH*SCALE, HEIGHT*SCALE, null);
g2.dispose();
}
//Overridden methods for the keyListener
public void keyPressed(KeyEvent key) {
gsm.keyPressed(key.getKeyCode());
}
public void keyReleased(KeyEvent key) {
gsm.keyReleased(key.getKeyCode());
}
public void keyTyped(KeyEvent e) {}
}
| [
"[email protected]"
] | |
694010df4613bd56a9ba4a6f4d8a0fb92df6f322 | ae8967f217cb7b91098151092ff561c3ee56008d | /src/was3/Dog.java | 428bd9411b080d03fdd2cea2efe2cffc38402066 | [] | no_license | apagabrys/Cezary-Pechcin-java | 3516bd0383bfe028f7fb3c904652383e05ed30ce | 0e1ece9f4864dbe650494f44c8ed9f591faad902 | refs/heads/master | 2021-08-27T23:28:58.295355 | 2017-12-10T19:11:24 | 2017-12-10T19:11:24 | 107,869,891 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,665 | java | package was3;
import java.util.ArrayList;
import java.util.List;
public class Dog extends Animal {
private Breed breed;
private boolean canSit;
private boolean canFetch;
private static int dogsCounter = 0;
private static List<Dog> dogCollection = new ArrayList<>();
public Dog(String name, int age, double weight, Breed breed) {
super(name, age, weight);
this.breed = breed;
this.canSit = false;
this.canFetch = false;
// System.out.println(super.getName() + " został stworzony.");
dogsCounter++;
dogCollection.add(this);
}
/* public void Sit(){
if(canSit){
System.out.println(this.name+" usiadł");
} else {
System.out.println(this.name+" nie zna tej komendy");
}
}
public void learnSit(){
this.canSit = true;
}
public void learnFetch(){
this.canFetch = true;
}
public String Fetch(){
if (canFetch){
return this.name+" zaaportował";
}
// else {
return this.name+ "nie umia paanie!";
// }
}
*/
public static List<Dog> getDogCollection() {
return dogCollection;
}
public static int getDogsCounter() {
return dogsCounter;
}
public Breed getBreed() {
return breed;
}
public void setBreed(Breed breed) {
this.breed = breed;
}
@Override
public String toString() {
return breed + " imieniem " + super.getName() + " ma lat "+ super.getAge();
}
@Override
public void makeSound(){
System.out.println(super.getName()+": Hau");
}
}
| [
"“nasz_email_do_github"
] | “nasz_email_do_github |
82b36b8c23513b9414019231346867f8403994e8 | 264e6df7a5021454d9391d03a8740cdd3fe1361f | /Ajax_Not_Now/AJAX_UPLOAD-DWR/ajax-upload-V2/WEB-INF/src/be/telio/mediastore/ui/upload/MonitoredOutputStream.java | 8fc68d55b4479b657f521913ef448bc30fd2797e | [] | no_license | debjava/AJAX | 8dae664efde6341db67d24c9011ae8ece861db9a | 2dc55049bfd38c03913c9d892e03d6314c7f939b | refs/heads/master | 2020-04-08T05:25:06.273996 | 2018-11-25T18:24:13 | 2018-11-25T18:24:13 | 159,059,660 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,479 | java | /* Licence:
* Use this however/wherever you like, just don't blame me if it breaks anything.
*
* Credit:
* If you're nice, you'll leave this bit:
*
* Class by Pierre-Alexandre Losson -- http://www.telio.be/blog
* email : [email protected]
*/
package be.telio.mediastore.ui.upload;
import java.io.OutputStream;
import java.io.IOException;
/**
* Created by IntelliJ IDEA.
*
* @author Original : plosson on 05-janv.-2006 10:44:18 - Last modified by $Author: plosson $ on $Date: 2006/01/05 10:44:49 $
* @version 1.0 - Rev. $Revision: 1.2 $
*/
public class MonitoredOutputStream extends OutputStream
{
private OutputStream target;
private OutputStreamListener listener;
public MonitoredOutputStream(OutputStream target, OutputStreamListener listener)
{
this.target = target;
this.listener = listener;
this.listener.start();
}
public void write(byte b[], int off, int len) throws IOException
{
target.write(b,off,len);
listener.bytesRead(len - off);
}
public void write(byte b[]) throws IOException
{
target.write(b);
listener.bytesRead(b.length);
}
public void write(int b) throws IOException
{
target.write(b);
listener.bytesRead(1);
}
public void close() throws IOException
{
target.close();
listener.done();
}
public void flush() throws IOException
{
target.flush();
}
}
| [
"[email protected]"
] | |
80532c304316fd8f66c486258ee56a8051b9fd50 | 6a13f10b18e17e6384cc4fa20e98b49bc5723abb | /Mall-api/src/main/java/com/server/api/model/jifenmodel/IndexBannerDetail.java | bb0efa08884cffb6ebe70ede1adfd40953d3efe0 | [] | no_license | gaoyuan117/Mall-Quna | f48a2ade9fb2d3717dfb46e01007684e80bfcd67 | 1d4fc95ffec7198d1f029b422a2d54a11c933438 | refs/heads/master | 2021-01-20T04:29:02.430190 | 2017-04-28T10:17:09 | 2017-04-28T10:17:09 | 89,694,910 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 496 | java | /*
* IndexBanner 2016/9/7-09-07
* Copyright (c) 2016 KOTERWONG All right reserved
*/
package com.server.api.model.jifenmodel;
import com.server.api.model.BaseEntity;
/**
* Created by Koterwong on 2016/9/7.
* Desc:
*/
public class IndexBannerDetail extends BaseEntity {
public Data[] data;
public static class Data {
public String id;
public String title;
public String content;
public String create_time;
public String image;
}
}
| [
"[email protected]"
] | |
f56d9a60c9cd0cabca840bf8ea5666bc57bfad57 | e4e08180fadd16c1e60ca0f12dc77ae729242054 | /6일차/restController/QnAServiceImpl.java | 58547967d8362ae5f1c19894ffa722718c6f1e67 | [] | no_license | OctopusSwellfish/TIL | 9b9736e61be611d9a90877dceaa652951220a4c8 | 157a27615f178e1df888870e28d39176fcbfaa85 | refs/heads/main | 2023-04-18T03:06:58.048802 | 2021-05-02T15:51:04 | 2021-05-02T15:51:04 | 311,527,996 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 859 | java | package com.ssafy.happyhouse.model.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ssafy.happyhouse.model.dao.QnADAO;
import com.ssafy.happyhouse.model.dto.QnA;
@Service
public class QnAServiceImpl implements QnAService{
private QnADAO qnaDao;
@Autowired
public void setQnaDao(QnADAO qnaDao) {
this.qnaDao = qnaDao;
}
@Override
public boolean createQnA(QnA qna) {
return qnaDao.insertQnA(qna)>0;
}
@Override
public boolean deleteQnA(int no) {
return qnaDao.deleteQnA(no) > 0;
}
@Override
public boolean updateQnA(QnA qna) {
return qnaDao.updateQnA(qna)>0;
}
@Override
public List<QnA> retrieveQnA() {
return qnaDao.selectQnA();
}
@Override
public QnA detailQnA(int no) {
return qnaDao.selectQnAByNo(no);
}
}
| [
"[email protected]"
] | |
a21e7c95069e61efe9b3a286d25f85e4e0437cb0 | eb5d7435ec8e085c4278a1a794a1a70616b54283 | /src/main/java/com/ldl/lotteryodds/train/TestTextBinary.java | 32cfe411b00a3a4e0ac22e45c4df826ce877caab | [] | no_license | wsldl123292/LotteryOdds | cd7c4f2264f9a5a6c3643d908afebe0e99a5e6f5 | e9cf5ee588d4d12fca0cf53ec7edb68fb114fc75 | refs/heads/master | 2021-01-18T21:30:45.888973 | 2018-05-31T14:13:40 | 2018-05-31T14:13:40 | 39,557,006 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 23,301 | java | package com.ldl.lotteryodds.train;
import com.alibaba.fastjson.JSON;
import com.google.common.base.Charsets;
import com.google.common.base.Splitter;
import com.google.common.io.Files;
import com.ldl.lotteryodds.entity.OddInfo;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 作者: LDL
* 说明: 生成待预测文本新版
* 时间: 2015/10/1 20:51
*/
public class TestTextBinary {
public static void main(String[] args) throws IOException {
//采集开始时间2011-07-21
LocalDate beginDate = LocalDate.of(2015, 11, 12);
int size = 1;
final CloseableHttpClient client = HttpClientBuilder.create().build();
CloseableHttpResponse response;
HttpGet get;
/** 列表地址 */
final String baseurl = "http://live.500.com/?e=";
/** 亚盘地址 */
final String yapanUrl = "http://odds.500.com/fenxi/yazhi-";
/** 欧赔地址 */
final String oupeiUrl = "http://odds.500.com/fenxi/ouzhi-";
/** 数据地址 */
final String shujuUrl = "http://odds.500.com/fenxi/shuju-";
String url;
final List<OddInfo> oddInfos = new ArrayList<>();
/**
* 采集列表页
*/
url = baseurl + beginDate.toString();
System.out.println("开始采集" + beginDate.toString() + "的数据");
try {
get = new HttpGet(url);
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.69 Safari/537.36 QQBrowser/9.1.4060.400");
response = client.execute(get);
final String bodyAsString = EntityUtils.toString(response.getEntity(), Charset.forName("gb2312"));
final Document document = Jsoup.parse(bodyAsString);
//获取比赛表格
final Element tableMatch = document.getElementById("table_match");
//解析赔率数据转换成map
/**
* var liveOddsList={"424899":{"0":[1.35,4.71,7.7],"3":[1.36,4.75,8.0],"5":[1.4,4.3,5.85],"rqsp":[1.89,3.55,3.15],"sp":[1.25,4.90,8.50],
* "280":[1.45,4.7,6.6],"293":[1.36,4.8,8.5]},"424900":{"0":[1.88,3.4,3.89],"3":[1.75,3.7,4.5],
* "5":[1.7,3.6,4.0],"rqsp":[3.45,3.50,1.81],"sp":[1.77,3.30,3.90],"280":[1.76,3.65,4.8],
* "293":[1.8,3.6,4.33]},"424901":{"0":[2.52,3.21,2.65],"3":[2.75,3.3,2.5],
* "5":[2.45,3.25,2.5],"rqsp":[5.35,4.40,1.40],"sp":[2.50,3.10,2.50],
* "280":[2.7,3.35,2.56],"293":[2.6,3.4,2.62]}};
*/
String odds = "";
final Elements scriptElements = document.getElementsByTag("script");
for (Object scriptElement : scriptElements) {
final Element element = (Element) scriptElement;
if (element.html().contains("liveOddsList")) {
odds = element.html();
break;
}
}
final Map<String, Object> liveOddsMap = (Map<String, Object>) JSON.parse(odds.substring("var liveOddsList=".length(),
odds.length() - 1));
final Map<String, Map<String, String>> oddMaps = new HashMap<>();
for (String key : liveOddsMap.keySet()) {
final String value = liveOddsMap.get(key).toString().replace("\"", "").replace("[", "")
.replace("],", "-").replace("{", "").replace("}", "").replace("]", "");
final Map<String, String> join = Splitter.on("-").withKeyValueSeparator(":").split(value);
oddMaps.put(key, join);
}
//解析每个tr转换为实体
final Elements trs = tableMatch.select("tbody>tr");
for (int i = 0; i < size; i++) {
//for (Object tr : trs) {
final Element element = trs.get(i);
if (!element.attr("parentid").trim().equals("")) {
continue;
}
/** 比赛id */
final String fid = element.attr("fid");
final OddInfo oddInfo = new OddInfo(fid);
oddInfo.setDate(beginDate.toString());
/** 比赛序号 */
oddInfo.setNumber(element.getElementsByTag("td").first().text());
/** 比分 */
final Elements socre = element.select(".pk");
/** 避免出现无比分情况 */
if (!socre.select(".clt1").text().trim().equals("")) {
oddInfo.setZscore(Integer.parseInt(socre.select(".clt1").text()));
oddInfo.setKscore(Integer.parseInt(socre.select(".clt3").text()));
oddInfo.setResult(oddInfo.getZscore(), oddInfo.getKscore());
}
/** 采集亚盘地址 http://odds.500.com/fenxi/yazhi-331954.shtml */
url = yapanUrl + fid + ".shtml";
get = new HttpGet(url);
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.69 Safari/537.36 QQBrowser/9.1.4060.400");
response = client.execute(get);
final String yapanBody = EntityUtils.toString(response.getEntity(), Charset.forName("gb2312"));
final Document yanpan = Jsoup.parse(yapanBody);
//获取亚盘数据表格
final Element ypDatatb = yanpan.getElementById("datatb");
final Elements yptrs = ypDatatb.select("tbody>tr").select("[xls=row]");
for (Element yptr : yptrs) {
if (yptr.attr("id").equals("5")) {
//澳门盘口信息
final Elements pks = yptr.select(".pl_table_data");
//最终盘口
final Elements lpktds = pks.get(0).select("tbody>tr>td");
oddInfo.setLzWaterAm(lpktds.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLpAm(lpktds.get(1).attr("ref"));
oddInfo.setLkWaterAm(lpktds.get(2).text().replace("↑", "").replace("↓", ""));
//初始盘口
final Elements cpktds = pks.get(1).select("tbody>tr>td");
oddInfo.setCzWaterAm(cpktds.get(0).text());
oddInfo.setCpAm(cpktds.get(1).attr("ref"));
oddInfo.setCkWaterAm(cpktds.get(2).text());
} else if (yptr.attr("id").equals("2")) {
//立博盘口信息
final Elements pks = yptr.select(".pl_table_data");
//最终盘口
final Elements lpktds = pks.get(0).select("tbody>tr>td");
oddInfo.setLzWaterLb(lpktds.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLpLb(lpktds.get(1).attr("ref"));
oddInfo.setLkWaterLb(lpktds.get(2).text().replace("↑", "").replace("↓", ""));
//初始盘口
final Elements cpktds = pks.get(1).select("tbody>tr>td");
oddInfo.setCzWaterLb(cpktds.get(0).text());
oddInfo.setCpLb(cpktds.get(1).attr("ref"));
oddInfo.setCkWaterLb(cpktds.get(2).text());
}
}
/** 采集欧赔地址 http://odds.500.com/fenxi/ouzhi-331954.shtml */
url = oupeiUrl + fid + ".shtml";
get = new HttpGet(url);
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.69 Safari/537.36 QQBrowser/9.1.4060.400");
response = client.execute(get);
final String oupeiBody = EntityUtils.toString(response.getEntity(), Charset.forName("gb2312"));
final Document oupei = Jsoup.parse(oupeiBody);
//获取欧赔数据表格
final Element opDatatb = oupei.getElementById("datatb");
final Elements optrs = opDatatb.select("tbody>tr").select("[xls=row]");
for (Element optr : optrs) {
if (optr.attr("id").equals("5")) {
//澳门欧赔信息
final Elements pks = optr.select(".pl_table_data");
final Elements cpktrs = pks.get(0).select("tbody>tr");
//初始赔率
final Elements cop = cpktrs.get(0).select("td");
oddInfo.setCwOddAm(cop.get(0).text());
oddInfo.setCdOddAm(cop.get(1).text());
oddInfo.setClOddAm(cop.get(2).text());
//最终赔率
final Elements lop = cpktrs.get(1).select("td");
oddInfo.setLwOddAm(lop.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdOddAm(lop.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlOddAm(lop.get(2).text().replace("↑", "").replace("↓", ""));
//凯利指数
final Elements klktrs = pks.get(3).select("tbody>tr");
//初始凯利指数
final Elements ckl = klktrs.get(0).select("td");
oddInfo.setCwKlAm(ckl.get(0).text());
oddInfo.setCdKlAm(ckl.get(1).text());
oddInfo.setClKlAm(ckl.get(2).text());
//最终凯利指数
final Elements lkl = klktrs.get(1).select("td");
oddInfo.setLwKlAm(lkl.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdKlAm(lkl.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlKlAm(lkl.get(2).text().replace("↑", "").replace("↓", ""));
} else if (optr.attr("id").equals("2")) {
//立博赔率信息
final Elements pks = optr.select(".pl_table_data");
final Elements cpktrs = pks.get(0).select("tbody>tr");
//初始赔率
final Elements cop = cpktrs.get(0).select("td");
oddInfo.setCwOddLb(cop.get(0).text());
oddInfo.setCdOddLb(cop.get(1).text());
oddInfo.setClOddLb(cop.get(2).text());
//最终赔率
final Elements lop = cpktrs.get(1).select("td");
oddInfo.setLwOddLb(lop.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdOddLb(lop.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlOddLb(lop.get(2).text().replace("↑", "").replace("↓", ""));
//凯利指数
final Elements klktrs = pks.get(3).select("tbody>tr");
//初始凯利指数
final Elements ckl = klktrs.get(0).select("td");
oddInfo.setCwKlLb(ckl.get(0).text());
oddInfo.setCdKlLb(ckl.get(1).text());
oddInfo.setClKlLb(ckl.get(2).text());
//最终凯利指数
final Elements lkl = klktrs.get(1).select("td");
oddInfo.setLwKlLb(lkl.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdKlLb(lkl.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlKlLb(lkl.get(2).text().replace("↑", "").replace("↓", ""));
} else if (optr.attr("id").equals("293")) {
//威廉希尔赔率信息
final Elements pks = optr.select(".pl_table_data");
final Elements cpktrs = pks.get(0).select("tbody>tr");
//初始赔率
final Elements cop = cpktrs.get(0).select("td");
oddInfo.setCwOddWl(cop.get(0).text());
oddInfo.setCdOddWl(cop.get(1).text());
oddInfo.setClOddWl(cop.get(2).text());
//最终赔率
final Elements lop = cpktrs.get(1).select("td");
oddInfo.setLwOddWl(lop.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdOddWl(lop.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlOddWl(lop.get(2).text().replace("↑", "").replace("↓", ""));
//凯利指数
final Elements klktrs = pks.get(3).select("tbody>tr");
//初始凯利指数
final Elements ckl = klktrs.get(0).select("td");
oddInfo.setCwKlWl(ckl.get(0).text());
oddInfo.setCdKlWl(ckl.get(1).text());
oddInfo.setClKlWl(ckl.get(2).text());
//最终凯利指数
final Elements lkl = klktrs.get(1).select("td");
oddInfo.setLwKlWl(lkl.get(0).text().replace("↑", "").replace("↓", ""));
oddInfo.setLdKlWl(lkl.get(1).text().replace("↑", "").replace("↓", ""));
oddInfo.setLlKlWl(lkl.get(2).text().replace("↑", "").replace("↓", ""));
}
}
/** 采集数据地址 http://odds.500.com/fenxi/shuju-331954.shtml */
url = shujuUrl + fid + ".shtml";
get = new HttpGet(url);
get.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.69 Safari/537.36 QQBrowser/9.1.4060.400");
response = client.execute(get);
final String shujunBody = EntityUtils.toString(response.getEntity(), Charset.forName("gb2312"));
final Document shuju = Jsoup.parse(shujunBody);
//获取双方交战记录
final Elements hits = shuju.select(".his_info");
Element hit = hits.first();
Elements f16 = hit.select(".f16");
if (f16 != null && f16.size() > 0) {
oddInfo.setWin(f16.select(".red").get(0).text().replace("胜", ""));
oddInfo.setDown(f16.select(".green").get(0).text().replace("平", ""));
oddInfo.setLose(f16.select(".blue").get(0).text().replace("负", ""));
}
//双方战绩
final Elements zhanjis = shuju.select(".bottom_info");
/** 主队近10场 */
Elements z = zhanjis.get(0).select(".mar_left20");
if (z != null && z.size() > 0) {
oddInfo.setZwin(z.get(0).select(".ying").get(0).text().replace("胜", ""));
oddInfo.setZdown(z.get(0).select(".ping").get(0).text().replace("平", ""));
oddInfo.setZlose(z.get(0).select(".shu").get(0).text().replace("负", ""));
oddInfo.setZjscore(Integer.parseInt(z.get(1).select(".ying").get(0).text().replace("球", "")));
oddInfo.setZlscore(Integer.parseInt(z.get(1).select(".shu").get(0).text().replace("球", "")));
}
/** 客队近10场 */
Elements k = zhanjis.get(1).select(".mar_left20");
if (k != null && k.size() > 0) {
oddInfo.setKwin(k.get(0).select(".ying").get(0).text().replace("胜", ""));
oddInfo.setKdown(k.get(0).select(".ping").get(0).text().replace("平", ""));
oddInfo.setKlose(k.get(0).select(".shu").get(0).text().replace("负", ""));
oddInfo.setKjscore(Integer.parseInt(k.get(1).select(".ying").get(0).text().replace("球", "")));
oddInfo.setKlscore(Integer.parseInt(k.get(1).select(".shu").get(0).text().replace("球", "")));
}
/** 主队近10主场 */
Elements zz = zhanjis.get(2).select(".mar_left20");
if (zz != null && zz.size() > 0) {
oddInfo.setZzwin(zz.get(0).select(".ying").get(0).text().replace("胜", ""));
oddInfo.setZzdown(zz.get(0).select(".ping").get(0).text().replace("平", ""));
oddInfo.setZzlose(zz.get(0).select(".shu").get(0).text().replace("负", ""));
oddInfo.setZzjscore(Integer.parseInt(zz.get(1).select(".ying").get(0).text().replace("球", "")));
oddInfo.setZzlscore(Integer.parseInt(zz.get(1).select(".shu").get(0).text().replace("球", "")));
}
/** 客队近10客场 */
Elements kk = zhanjis.get(3).select(".mar_left20");
if (kk != null && kk.size() > 0) {
oddInfo.setKkwin(kk.get(0).select(".ying").get(0).text().replace("胜", ""));
oddInfo.setKkdown(kk.get(0).select(".ping").get(0).text().replace("平", ""));
oddInfo.setKklose(kk.get(0).select(".shu").get(0).text().replace("负", ""));
oddInfo.setKkjscore(Integer.parseInt(kk.get(1).select(".ying").get(0).text().replace("球", "")));
oddInfo.setKklsocre(Integer.parseInt(kk.get(1).select(".shu").get(0).text().replace("球", "")));
}
oddInfos.add(oddInfo);
}
} catch (IOException e) {
e.printStackTrace();
}
if (oddInfos.size() > 0) {
final StringBuilder stringBuffer = new StringBuilder();
for (OddInfo oddInfo : oddInfos) {
stringBuffer
/*.append(oddInfo.getCwOddAm()).append("\t")
.append(oddInfo.getCdOddAm()).append("\t")
.append(oddInfo.getClOddAm()).append("\t")
.append(oddInfo.getLwOddAm()).append("\t")
.append(oddInfo.getLdOddAm()).append("\t")
.append(oddInfo.getLlOddAm()).append("\t")
.append(oddInfo.getCwKlAm()).append("\t")
.append(oddInfo.getCdKlAm()).append("\t")
.append(oddInfo.getClKlAm()).append("\t")
.append(oddInfo.getLwKlAm()).append("\t")
.append(oddInfo.getLdKlAm()).append("\t")
.append(oddInfo.getLlKlAm()).append("\t")
.append(oddInfo.getCzWaterAm()).append("\t")
.append(oddInfo.getCpAm()).append("\t")
.append(oddInfo.getCkWaterAm()).append("\t")
.append(oddInfo.getLzWaterAm()).append("\t")
.append(oddInfo.getLpAm()).append("\t")
.append(oddInfo.getLkWaterAm()).append("\t")
.append(oddInfo.getCwOddLb()).append("\t")
.append(oddInfo.getCdOddLb()).append("\t")
.append(oddInfo.getClOddLb()).append("\t")
.append(oddInfo.getLwOddLb()).append("\t")
.append(oddInfo.getLdOddLb()).append("\t")
.append(oddInfo.getLlOddLb()).append("\t")
.append(oddInfo.getCwKlLb()).append("\t")
.append(oddInfo.getCdKlLb()).append("\t")
.append(oddInfo.getClKlLb()).append("\t")
.append(oddInfo.getLwKlLb()).append("\t")
.append(oddInfo.getLdKlLb()).append("\t")
.append(oddInfo.getLlKlLb()).append("\t")
.append(oddInfo.getCzWaterLb()).append("\t")
.append(oddInfo.getCpLb()).append("\t")
.append(oddInfo.getCkWaterLb()).append("\t")
.append(oddInfo.getLzWaterLb()).append("\t")
.append(oddInfo.getLpLb()).append("\t")
.append(oddInfo.getLkWaterLb()).append("\t")
.append(oddInfo.getCwOddWl()).append("\t")
.append(oddInfo.getCdOddWl()).append("\t")
.append(oddInfo.getClOddWl()).append("\t")
.append(oddInfo.getLwOddWl()).append("\t")
.append(oddInfo.getLdOddWl()).append("\t")
.append(oddInfo.getLlOddWl()).append("\t")
.append(oddInfo.getCwKlWl()).append("\t")
.append(oddInfo.getCdKlWl()).append("\t")
.append(oddInfo.getClKlWl()).append("\t")
.append(oddInfo.getLwKlWl()).append("\t")
.append(oddInfo.getLdKlWl()).append("\t")
.append(oddInfo.getLlKlWl()).append("\t")
.append(oddInfo.getWin()).append("\t")
.append(oddInfo.getDown()).append("\t")
.append(oddInfo.getLose()).append("\t")
.append(oddInfo.getZwin()).append("\t")
.append(oddInfo.getZdown()).append("\t")
.append(oddInfo.getZlose()).append("\t")
.append(oddInfo.getKwin()).append("\t")
.append(oddInfo.getKdown()).append("\t")
.append(oddInfo.getKlose()).append("\t")
.append(oddInfo.getZzwin()).append("\t")
.append(oddInfo.getZzdown()).append("\t")
.append(oddInfo.getZzlose()).append("\t")
.append(oddInfo.getKkwin()).append("\t")
.append(oddInfo.getKkdown()).append("\t")
.append(oddInfo.getKklose()).append("\t")*/
.append(oddInfo.getLlOddWl()).append("\t")
//.append(oddInfo.getLlOddLb()).append("\t")
.append(oddInfo.getType()).append("\t")
.append(oddInfo.getNumber()).append("\n");
}
Files.write(stringBuffer.toString(), new File("test_all_binary.txt"), Charsets.UTF_8);
}
}
}
| [
"[email protected]"
] | |
15b1a83a936cd27ba0f40ac772458a1176ed7b6a | 7c0bf9aa980fb49794b521a61a834473c61f478b | /Algorithm/src/main/java/shumei/one.java | b1cc07da9bbbb144cfc1af31b91656489b6dd4e2 | [] | no_license | pl-jhin/studyJava | ba0084c946411351f25d79969656d32e9b713514 | 8bc46b58b495970cecbd24ab5ab2f2e1cf8a8a08 | refs/heads/master | 2023-05-12T00:18:42.080616 | 2021-06-03T00:00:11 | 2021-06-03T00:00:11 | 367,874,474 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,034 | java | package shumei;
import java.util.Arrays;
public class one {
public static void main(String[] args) {
int[] a = {1,3,5,7,9};
int[] b = {2,4,6,8,10,11};
System.out.println(Arrays.toString(hebing(a,b)));
}
private static int[] hebing(int[] one, int[] tow) {
//定义数组
int[] result = new int[one.length + tow.length];
int i = 0, j = 0;
int overIndex = 0;
//先加入到新数组
while (i < one.length && j < tow.length) {
if (one[i] < tow[j]) {
result[overIndex++] = one[i++];
} else {
result[overIndex++] = tow[j++];
}
}
int l;
//多出的长度
if (one.length<tow.length){
for (l = j; l < tow.length; l++) {
result[overIndex++] = tow[l];
}
}else {
for (l = i; l < one.length; l++) {
result[overIndex++] = one[l];
}
}
return result;
}
}
| [
"[email protected]"
] | |
0fdae819a7b31ae97e74d89aeed1eb2b4305eccb | da944dcd46252b90d9e1c8c878157928f2656149 | /common/build/tmp/kapt3/stubs/debug/com/tawabsoft/taxi/common/utils/LocationHelper.java | 6be565e179ca540ac300901e0b189fc052f192ee | [] | no_license | RamadanElSayed/android | f1b3cdaa345f47b25eca4a4ad38a727cdbabd43a | 1d926542e751f5bd7a3d74e3d5a89e21ab8f4fb5 | refs/heads/master | 2023-01-03T07:03:29.829644 | 2020-11-02T01:08:04 | 2020-11-02T01:08:04 | 308,673,036 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,422 | java | package com.tawabsoft.taxi.common.utils;
import java.lang.System;
@kotlin.Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\u0000 \n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u0018\u0000 \t2\u00020\u0001:\u0001\tB\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u00a2\u0006\u0002\u0010\u0004J\u0010\u0010\u0005\u001a\u00020\u00062\b\u0010\u0007\u001a\u0004\u0018\u00010\bR\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004\u00a2\u0006\u0002\n\u0000\u00a8\u0006\n"}, d2 = {"Lcom/tawabsoft/taxi/common/utils/LocationHelper;", "", "con", "Landroid/content/Context;", "(Landroid/content/Context;)V", "loadGps", "", "listener", "Landroid/location/LocationListener;", "Companion", "common_debug"})
public final class LocationHelper {
private final android.content.Context con = null;
@org.jetbrains.annotations.Nullable()
private static android.location.LocationManager locationManager;
public static final com.tawabsoft.taxi.common.utils.LocationHelper.Companion Companion = null;
public final void loadGps(@org.jetbrains.annotations.Nullable()
android.location.LocationListener listener) {
}
public LocationHelper(@org.jetbrains.annotations.NotNull()
android.content.Context con) {
super();
}
public static final int distFrom(@org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng latLng1, @org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng latLng2) {
return 0;
}
@org.jetbrains.annotations.NotNull()
public static final double[] LatLngToDoubleArray(@org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng position) {
return null;
}
@org.jetbrains.annotations.NotNull()
public static final com.google.android.gms.maps.model.LatLng DoubleArrayToLatLng(@org.jetbrains.annotations.NotNull()
double[] position) {
return null;
}
@kotlin.Metadata(mv = {1, 1, 16}, bv = {1, 0, 3}, k = 1, d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0013\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002\u00a2\u0006\u0002\u0010\u0002J\u0010\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\fH\u0007J\u0010\u0010\r\u001a\u00020\f2\u0006\u0010\u000b\u001a\u00020\nH\u0007J\u0018\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\n2\u0006\u0010\u0011\u001a\u00020\nH\u0007R\u001c\u0010\u0003\u001a\u0004\u0018\u00010\u0004X\u0086\u000e\u00a2\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\b\u00a8\u0006\u0012"}, d2 = {"Lcom/tawabsoft/taxi/common/utils/LocationHelper$Companion;", "", "()V", "locationManager", "Landroid/location/LocationManager;", "getLocationManager", "()Landroid/location/LocationManager;", "setLocationManager", "(Landroid/location/LocationManager;)V", "DoubleArrayToLatLng", "Lcom/google/android/gms/maps/model/LatLng;", "position", "", "LatLngToDoubleArray", "distFrom", "", "latLng1", "latLng2", "common_debug"})
public static final class Companion {
@org.jetbrains.annotations.Nullable()
public final android.location.LocationManager getLocationManager() {
return null;
}
public final void setLocationManager(@org.jetbrains.annotations.Nullable()
android.location.LocationManager p0) {
}
public final int distFrom(@org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng latLng1, @org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng latLng2) {
return 0;
}
@org.jetbrains.annotations.NotNull()
public final double[] LatLngToDoubleArray(@org.jetbrains.annotations.NotNull()
com.google.android.gms.maps.model.LatLng position) {
return null;
}
@org.jetbrains.annotations.NotNull()
public final com.google.android.gms.maps.model.LatLng DoubleArrayToLatLng(@org.jetbrains.annotations.NotNull()
double[] position) {
return null;
}
private Companion() {
super();
}
}
} | [
"[email protected]"
] | |
4471a773eb23be1cb058ceffb52ab75f83439a83 | 28642562f2090c32c84a8f051afa974c16c1eba8 | /src/main/java/com/antiphishing/utils/whoisparsers/FrParser.java | 193d72def00bd761be915b4018188f73220b3859 | [] | no_license | anealo/whoisutil | 7e9a30c3190d4fea34ed400a1ced02ece877a03f | 33c8f968cac875f61ab2fe65becf2ef984328c25 | refs/heads/master | 2020-04-19T15:20:47.053278 | 2017-11-19T12:31:25 | 2017-11-19T12:31:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,028 | java | package com.antiphishing.utils.whoisparsers;
import com.antiphishing.models.WhoisModel;
import com.antiphishing.utils.IpUtil;
import java.text.SimpleDateFormat;
import java.util.regex.Pattern;
/**
* Created by dell on 2017/11/16.
*/
/**
* %%
%% This is the AFNIC Whois server.
%%
%% complete date format : DD/MM/YYYY
%% short date format : DD/MM
%% version : FRNIC-2.5
%%
%% Rights restricted by copyright.
%% See https://www.afnic.fr/en/products-and-services/services/whois/whois-special-notice/
%%
%% Use '-h' option to obtain more information about this service.
%%
%% [119.97.214.138 REQUEST] >> coe.fr
%%
%% RL Net [##########] - RL IP [#########.]
%%
domain: coe.fr
status: ACTIVE
hold: NO
holder-c: ANO00-FRNIC
admin-c: OVH5-FRNIC
tech-c: OVH5-FRNIC
zone-c: NFC1-FRNIC
nsl-id: NSL40848-FRNIC
registrar: OVH
Expiry Date: 28/05/2018
created: 24/08/2006
last-update: 28/05/2017
source: FRNIC
ns-list: NSL40848-FRNIC
nserver: ns17.ovh.net
nserver: dns17.ovh.net
source: FRNIC
registrar: OVH
type: Isp Option 1
address: 2 Rue Kellermann
address: 59100 ROUBAIX
country: FR
phone: +33 8 99 70 17 61
fax-no: +33 3 20 20 09 58
e-mail: [email protected]
website: http://www.ovh.com
anonymous: NO
registered: 21/10/1999
source: FRNIC
nic-hdl: ANO00-FRNIC
type: PERSON
contact: Ano Nymous
remarks: -------------- WARNING --------------
remarks: While the registrar knows him/her,
remarks: this person chose to restrict access
remarks: to his/her personal data. So PLEASE,
remarks: don't send emails to Ano Nymous. This
remarks: address is bogus and there is no hope
remarks: of a reply.
remarks: -------------- WARNING --------------
registrar: OVH
changed: 31/12/2014 anonymous@anonymous
anonymous: YES
obsoleted: NO
eligstatus: ok
eligdate: 31/12/2014 00:33:05
source: FRNIC
nic-hdl: OVH5-FRNIC
type: ROLE
contact: OVH NET
address: OVH
address: 140, quai du Sartel
address: 59100 Roubaix
country: FR
phone: +33 8 99 70 17 61
e-mail: [email protected]
trouble: Information: http://www.ovh.fr
trouble: Questions: mailto:[email protected]
trouble: Spam: mailto:[email protected]
admin-c: OK217-FRNIC
tech-c: OK217-FRNIC
notify: [email protected]
registrar: OVH
changed: 11/10/2006 [email protected]
anonymous: NO
obsoleted: NO
source: FRNIC
*/
public class FrParser extends AParser{
private FrParser(){}
private static FrParser instance = null;
public static FrParser getInstance(){
if(instance == null){
instance = new FrParser();
}
return instance;
}
private final String DOMAINREG = "\\s*domain:\\s*[^\\n]+";
private final String CONTACTSREG = "\\s*admin\\-c:\\s*[^\\n]+";
private final String CTIMEREG = "\\s*created:\\s*[^\\n]+";
private final String UTIMEREG = "\\s*last\\-update:\\s*[^\\n]+";
private final String EMAILREG = "\\s*e\\-mail:\\s*[^\\n]+";
private final String PHONEREG = "\\s*phone:\\s*[^\\n]+";
private Pattern domainPattern = Pattern.compile(DOMAINREG);
private Pattern contactsPattern = Pattern.compile(CONTACTSREG);
private Pattern ctimePattern = Pattern.compile(CTIMEREG);
private Pattern utimePattern = Pattern.compile(UTIMEREG);
private Pattern emailPattern = Pattern.compile(EMAILREG);
private Pattern phonePattern = Pattern.compile(PHONEREG);
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyyy");
@Override
public WhoisModel parseWhois(String whoisResponse) {
WhoisModel whoisModel = new WhoisModel();
try {
String domain = getFieldValue(getMatchField(domainPattern, whoisResponse), ":");
whoisModel.setDomain(domain);
String contacts = getFieldValue(getMatchField(contactsPattern, whoisResponse), ":");
whoisModel.setContacts(contacts);
String ctime = getFieldValue(getMatchField(ctimePattern, whoisResponse), ":");
whoisModel.setCtime(simpleDateFormat.parse(ctime).getTime());
String utime = getFieldValue(getMatchField(utimePattern, whoisResponse), ":");
whoisModel.setUtime(simpleDateFormat.parse(utime).getTime());
whoisModel.setIp(IpUtil.getIpByDomain(domain));
String email = getFieldValue(getMatchField(emailPattern, whoisResponse), ":");
whoisModel.setEmail(email);
String phone = getFieldValue(getMatchField(phonePattern, whoisResponse), ":");
whoisModel.setPhone(phone);
}catch(Exception ex){
ex.printStackTrace();
}
return whoisModel;
}
}
| [
"[email protected]"
] | |
b9327a578fe2b8ed58698d3bdee93804e27bac07 | f3d2df2f2aff927bad0b6bae713fc93dcbba052c | /src/me/daddychurchill/CityWorld/Plugins/SurfaceProvider_Sanddunes.java | 5439f6a1305d9769bfe51cfecc2ba56d8251523e | [] | no_license | lazareth241/CityWorld | dbbb8f709d3df905138c5f58db41339edffeb70b | 9112f4fb1f50ff30b18bb09c38dced3975038dda | refs/heads/master | 2021-01-16T20:42:59.610649 | 2013-05-24T16:49:45 | 2013-05-24T16:49:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 291 | java | package me.daddychurchill.CityWorld.Plugins;
import me.daddychurchill.CityWorld.Support.Odds;
public class SurfaceProvider_Sanddunes extends SurfaceProvider_Normal {
public SurfaceProvider_Sanddunes(Odds odds) {
super(odds);
// TODO Auto-generated constructor stub
}
}
| [
"[email protected]"
] | |
00ac245fbaade9a15627c823f2522e76b81f609f | f6a78b42a0ed803c9dff2ca51eed1d9dec4f8384 | /src/main/java/entities/Person.java | 10d7c344feb7048326651a0b0138190025089c02 | [] | no_license | KarolPiasnik/Clinic-Management-System | 6b312cf690f998e2dd75a4dc37d6532a3a9d7f19 | d62097b02f774c8d10b97ce0f860a78876080a26 | refs/heads/master | 2020-04-01T23:38:01.118304 | 2018-10-19T11:04:34 | 2018-10-19T11:04:34 | 153,766,376 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,375 | java | package entities;
import com.mongodb.BasicDBObject;
import com.mongodb.DBObject;
import enums.SexEnum;
public class Person {
Object id;
protected String name;
protected String surname;
protected String pesel;
protected Integer age;
protected SexEnum sex;
public Person() {
}
public Person(String name, String surname, String pesel, Integer age, SexEnum sex) {
this.id = null;
this.name = name;
this.surname = surname;
this.sex = sex;
this.pesel = pesel;
this.age = age;
}
public Person(DBObject person) {
this.id = person.get("_id");
this.name = person.get("name").toString();
this.surname = person.get("surname").toString();
this.sex = SexEnum.values()[(Integer) person.get("sex")];
this.pesel = person.get("pesel").toString();
this.age = (Integer) person.get("age");
}
public Object getId() {
return id;
}
public void setId(Object id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getPesel() {
return pesel;
}
public void setPesel(String pesel) {
this.pesel = pesel;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public SexEnum getSex() {
return sex;
}
public void setSex(SexEnum sex) {
this.sex = sex;
}
public BasicDBObject toDBObject() {
BasicDBObject dbobject = new BasicDBObject();
if (this.getName() != null)
dbobject.append("name", this.getName());
if (this.getSurname() != null)
dbobject.append("surname", this.getSurname());
if (this.getPesel() != null)
dbobject.append("pesel", this.getPesel());
if (this.getAge() != null)
dbobject.append("age", this.getAge());
if (this.getSex() != null)
dbobject.append("sex", this.getSex().ordinal());
if (id != null) {
dbobject.append("_id", id);
}
return dbobject;
}
}
| [
"[email protected]"
] | |
acd0500e64ec968a380a224f38fb2260d74c8582 | 11e2dcfef786733e6a475c721ad16b55865488f9 | /app/src/main/java/com/tsa/NCC_dte_punjab/fragments/ShowPDFFragment.java | 4aa0a0f4a4627e164549f36ad99eed0ee7282f25 | [] | no_license | jayeshmann/ncc | 754c44580cbdaed6d357996109875ccee66ac72d | 7561b4aac2fd8c1bb9dfae099cd5381667a6cc94 | refs/heads/master | 2020-05-31T22:55:08.393955 | 2019-06-06T06:46:11 | 2019-06-06T06:46:11 | 190,528,985 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,550 | java | package com.tsa.NCC_dte_punjab.fragments;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import com.tsa.NCC_dte_punjab.R;
import com.tsa.NCC_dte_punjab.custom.MyWebViewClient;
public class ShowPDFFragment extends Fragment {
private View view;
private WebView webView;
private String urls[]=new String[]{"http://nccindia.nic.in/sites/default/files/NCC+Act+1948.pdf",""};
//https://docs.google.com/viewerng/viewer?url=http://nccindia.nic.in/sites/default/files/NCC+ACT+and+Rules++Dec+1948.pdf
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup
content_frame, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_show_pdf, content_frame, false);
init();
return view;
}
private void init() {
webView=(WebView)view.findViewById(R.id.webview);
webView.setWebViewClient(new MyWebViewClient());
// String myPdfUrl =GLOBAL.url "https://www.tsassessors.com/sanya-shakti/content/TRAINING/CAMP/CAMP_SOP.docx";
String url = "http://docs.google.com/gview?embedded=true&url=" + urls[0];
//Log.i("TAG", "Opening PDF: " + url);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl(url);
/////////////////////////////////////////////////////////
}
} | [
"[email protected]"
] | |
b1c33cc3b85aab9021324d3a15129e38f8ae85af | c561eb31c07d34448a61f1bdceafc10f6ffc5968 | /src/main/java/com/lg/leetcode/other/practice1/LFUCache.java | f859bb577f8bb052a317358ddbeacb3ffd914c2c | [] | no_license | x55555lg/data-structure-and-algorithm | 4d9ab12b3f23b401f2a89f1fe0226dc8702dfe66 | 025c0c7b85af11549491319e38cace2a4fbf926b | refs/heads/master | 2022-07-06T11:30:38.343970 | 2021-11-28T12:32:27 | 2021-11-28T12:32:27 | 216,988,364 | 2 | 0 | null | 2022-06-17T02:37:12 | 2019-10-23T06:53:49 | Java | UTF-8 | Java | false | false | 3,058 | java | package com.lg.leetcode.other.practice1;
/**
* @author Xulg
* Created in 2021-05-10 17:10
*/
class LFUCache {
/*
* Design and implement a data structure for a Least Frequently Used (LFU) cache.
* Implement the LFUCache class:
* LFUCache(int capacity) Initializes the object with the capacity of the data structure.
* int get(int key) Gets the value of the key if the key exists in the cache. Otherwise, returns -1.
* void put(int key, int value) Update the value of the key if present, or inserts the key if not already present.
* When the cache reaches its capacity, it should invalidate and remove the least frequently used key before
* inserting a new item. For this problem, when there is a tie (i.e., two or more keys with the same frequency),
* the least recently used key would be invalidated. To determine the least frequently used key, a use counter
* is maintained for each key in the cache. The key with the smallest use counter is the least frequently used key.
*
* When a key is first inserted into the cache, its use counter is set to 1 (due to the put operation).
* The use counter for a key in the cache is incremented either a get or put operation is called on it.
*
* Example 1:
* Input
* ["LFUCache", "put", "put", "get", "put", "get", "get", "put", "get", "get", "get"]
* [[2], [1, 1], [2, 2], [1], [3, 3], [2], [3], [4, 4], [1], [3], [4]]
* Output
* [null, null, null, 1, null, -1, 3, null, -1, 3, 4]
*
* Explanation
* // cnt(x) = the use counter for key x
* // cache=[] will show the last used order for tiebreakers (leftmost element is most recent)
* LFUCache lfu = new LFUCache(2);
* lfu.put(1, 1); // cache=[1,_], cnt(1)=1
* lfu.put(2, 2); // cache=[2,1], cnt(2)=1, cnt(1)=1
* lfu.get(1); // return 1
* // cache=[1,2], cnt(2)=1, cnt(1)=2
* lfu.put(3, 3); // 2 is the LFU key because cnt(2)=1 is the smallest, invalidate 2.
* // cache=[3,1], cnt(3)=1, cnt(1)=2
* lfu.get(2); // return -1 (not found)
* lfu.get(3); // return 3
* // cache=[3,1], cnt(3)=2, cnt(1)=2
* lfu.put(4, 4); // Both 1 and 3 have the same cnt, but 1 is LRU, invalidate 1.
* // cache=[4,3], cnt(4)=1, cnt(3)=2
* lfu.get(1); // return -1 (not found)
* lfu.get(3); // return 3
* // cache=[3,4], cnt(4)=1, cnt(3)=3
* lfu.get(4); // return 4
* // cache=[3,4], cnt(4)=2, cnt(3)=3
*
* Constraints:
* 0 <= capacity, key, value <= 104
* At most 105 calls will be made to get and put.
*
* Follow up: Could you do both operations in O(1) time complexity?
*/
private static class MyLFUCache {
public int get(int key) {
return -1;
}
public void put(int key, int value) {
}
}
public static void main(String[] args) {
}
}
| [
"[email protected]"
] | |
81fc0a81d4874946a4841d1a1c1ef6e8492f082c | 58863f68507d0b5d4d64e15899f1b60b8978b218 | /src/main/java/leetcode/P1672RichestCustomer.java | 9ae29734f0f070d800152fcc57a06028f3a7ce06 | [] | no_license | Bharat9848/algopractice | 7774de369d6790b4fbcec33ab0bbe67bdcecaa48 | 52a81a8e3f9a182315819cd0d8ce77397e99414b | refs/heads/master | 2022-08-25T17:50:58.854545 | 2022-07-16T05:17:58 | 2022-07-16T05:17:58 | 135,737,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,630 | java | package leetcode;
/*
72. Richest Customer Wealth
User Accepted:4370
User Tried:4436
Total Accepted:4425
Total Submissions:4630
Difficulty:Easy
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. Return the wealth that the richest customer has.
A customer's wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth.
Example 1:
Input: accounts = [[1,2,3],[3,2,1]]
Output: 6
Explanation:
1st customer has wealth = 1 + 2 + 3 = 6
2nd customer has wealth = 3 + 2 + 1 = 6
Both customers are considered the richest with a wealth of 6 each, so return 6.
Example 2:
Input: accounts = [[1,5],[7,3],[3,5]]
Output: 10
Explanation:
1st customer has wealth = 6
2nd customer has wealth = 10
3rd customer has wealth = 8
The 2nd customer is the richest with a wealth of 10.
Example 3:
Input: accounts = [[2,8,7],[7,1,3],[1,9,5]]
Output: 17
Constraints:
m == accounts.length
n == accounts[i].length
1 <= m, n <= 50
1 <= accounts[i][j] <= 100
*/
public class P1672RichestCustomer {
public int maximumWealth(int[][] accounts) {
int max = 0;
for(int i = 0; i< accounts.length; i++){
int custi =0;
for(int j=0; j< accounts[0].length; j++){
custi += accounts[i][j];
}
if(max<custi){
max = custi;
}
}
return max;
}
}
| [
"[email protected]"
] | |
3382185a3325c5df897b7ce7d8d2742f936bf95d | 8272cd0c387d4f7cd63c2eca3f258c7448f534c5 | /src/test/dataStructures/ArrayTest.java | a3e19edf06e4351cf5d81e770189dc2ddcff33c7 | [] | no_license | matufajus/ADS | 20d624498800fed9ec2a547eb1dce0f7af4114da | 8ce9520cf27f0bd24b94cd9a6429787fe1d78acf | refs/heads/master | 2022-09-27T05:59:32.547350 | 2020-06-05T08:49:06 | 2020-06-05T09:31:19 | 269,584,570 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 621 | java | package test.dataStructures;
import static org.junit.jupiter.api.Assertions.*;
import java.util.HashSet;
import java.util.Set;
import org.junit.jupiter.api.Test;
import main.dataStructures.Array;
class ArrayTest {
@Test
void testRemoveDuplicates() {
int[] a = {5, 6, 5, 3, 4, 6, 1};
Array array = new Array(a);
array.removeDuplicates();
int[] b = {5, 6, 3, 4, 1};
assertArrayEquals(b, array.toArray());
}
@Test
void testReverse() {
int[] a = {5, 6, 5, 3, 4, 6, 1};
Array array = new Array(a);
array.reverse();
int[] b = {1, 6, 4, 3, 5, 6, 5};
assertArrayEquals(b, array.toArray());
}
}
| [
"[email protected]"
] | |
0c469ef3ba7a532649f02b0df6c3fe828908e3d5 | 4f8e8140064091181bb2663b20b9efb128d4ac92 | /backend/service/src/main/java/com/studyboard/config/PasswordEncoderConfig.java | 7063bbcd4cf6c628a54061bd5657aa148c655907 | [
"MIT"
] | permissive | Sommerio/Studyboard-ASE | db526927b7b771a98a3af9c44b75733cf2f56ab8 | c6b06b8c42a1ba0905f9bc0c1945025f1d5b1ec7 | refs/heads/main | 2023-04-30T05:50:22.587297 | 2021-06-02T14:04:09 | 2021-06-02T14:04:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 475 | java | package com.studyboard.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
@Configuration
public class PasswordEncoderConfig {
@Bean
public static PasswordEncoder configureDefaultPasswordEncoder() {
return new BCryptPasswordEncoder(10);
}
}
| [
"[email protected]"
] | |
f5937808d795def741ff67b52ceac2e6e9b162b8 | e48aa5ce3aa5c3170d2dbc6f88f409e9749f926a | /src/edu/uta/futureye/function/test/COperator.java | 4a3f109a51700df6c3f457c20e9ca7f6ee8c2ba5 | [] | no_license | ikyaqoob/Futureye_v2 | 23ef87b24204790286c2aadadd2a7f2b4b36389d | 9723b411acd5317d0507fc89d7f67b5cfe2f5be7 | refs/heads/master | 2021-01-13T15:02:31.865460 | 2017-01-15T17:52:15 | 2017-01-15T17:52:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,035 | java | package edu.uta.futureye.function.test;
import java.util.List;
import edu.uta.futureye.util.Constant;
public class COperator {
/**
* item * pChain
* @param pChain
* @param item
* @return
*/
public static PlusChain PlusChainMultiItem(PlusChain pChain, Item item) {
if(item instanceof MultiChain)
return PlusChainMultiMultiChain(pChain,(MultiChain)item);
else if(item instanceof PlusChain)
return PlusChainMultiPlusChain(pChain,(PlusChain)item);
else {
PlusChain pc = new PlusChain();
for(ItemPair pair : pChain.getAllItem()) {
MultiChain mc = new MultiChain();
if(Math.abs(pair.coef-1.0) > Constant.eps)
mc.addItem(new ItemPair(pair.coef));
mc.addItem(new ItemPair(1.0,pair.item));
mc.addItem(new ItemPair(1.0,item));
pc.addItem(mc.reduceToItemPair());
}
return pc;
}
}
/**
* pChain * mChain
* @param pChain
* @param mChain
* @return
*/
public static PlusChain PlusChainMultiMultiChain(PlusChain pChain, MultiChain mChain) {
PlusChain pc = new PlusChain();
for(ItemPair pair : pChain.getAllItem()) {
MultiChain mc = new MultiChain();
if(Math.abs(pair.coef-1.0) > Constant.eps)
mc.addItem(new ItemPair(pair.coef));
mc.addItem(new ItemPair(1.0,pair.item));
mc.addAllItem(mChain.getAllItem());
pc.addItem(mc.reduceToItemPair());
}
return pc;
}
/**
* pChain1 * pChain2
* @param pChain1
* @param pChain2
* @return
*/
public static PlusChain PlusChainMultiPlusChain(PlusChain pChain1, PlusChain pChain2) {
PlusChain pc = new PlusChain();
for(ItemPair pair1 : pChain1.getAllItem()) {
for(ItemPair pair2 : pChain2.getAllItem()) {
MultiChain mc = new MultiChain();
double coef = pair1.coef * pair2.coef;
if(Math.abs(coef-1.0) > Constant.eps)
mc.addItem(new ItemPair(coef));
mc.addItem(new ItemPair(1.0,pair1.item));
mc.addItem(new ItemPair(1.0,pair2.item));
pc.addItem(mc.reduceToItemPair());
}
}
return pc;
}
public static Chain ReduceChain(Chain chain) {
chain.merge(true);
if(chain instanceof PlusChain) {
for(int i=0;i<chain.length();i++) {
ItemPair pair = chain.getItem(i);
if(Math.abs(pair.coef)<Constant.eps)
pair.item = new GhostItem();
}
} else if(chain instanceof MultiChain) {
for(int i=0;i<chain.length();i++) {
ItemPair pair = chain.getItem(i);
if(Math.abs(pair.coef)<Constant.eps && !(pair.item instanceof GhostItem)) {
pair.coef = 1.0;
pair.item = new GhostItem();
}
}
chain.merge(false);
}
if(chain.length() == 1) {
if(chain instanceof PlusChain) {
ItemPair pair = chain.getItem(0);
Item item = pair.item;
if(pair.item instanceof Function) {
Chain sub = ((Function)pair.item).getChain();
item = sub;
}
if(item instanceof PlusChain) {
PlusChain pc = (PlusChain)((PlusChain)item).copy();
pc.multiCoef(pair.coef);
return ReduceChain(pc);
} else if(item instanceof MultiChain) {
MultiChain mc = (MultiChain)((MultiChain)item).copy();
mc.addItem(new ItemPair(pair.coef));
return ReduceChain(mc);
}
} else if(chain instanceof MultiChain) {
ItemPair pair = chain.getItem(0);
Item item = pair.item;
if(pair.item instanceof Function) {
Chain sub = ((Function)pair.item).getChain();
item = sub;
}
if(item instanceof PlusChain) {
if(Math.abs(pair.coef-1.0) < Constant.eps) {
return ReduceChain((Chain)item);
}
} else if(item instanceof MultiChain) {
if(Math.abs(pair.coef-1.0) < Constant.eps)
return ReduceChain((Chain)item);
}
}
}
return chain;
}
/**
*
* @param chain
* @return
*/
public static Chain ExpandChain(Chain chain) {
chain.merge(true);
chain = ReduceChain(chain);
if(chain instanceof PlusChain) {
PlusChain tmp = (PlusChain)chain.copy();
List<ItemPair> list = tmp.getAllItem();
for(int i=0;i<list.size();i++) {
ItemPair pair = list.get(i);
if(pair.item instanceof Chain)
pair.item = ReduceChain((Chain)pair.item);
if(pair.item instanceof MultiChain) {
pair.item = ExpandChain((Chain)pair.item);//Update Item
if(pair.item instanceof MultiChain) {
ItemPair reduced = ((MultiChain)pair.item).reduceToItemPair();
pair.coef *= reduced.coef;
pair.item = reduced.item;
} else if(pair.item instanceof PlusChain) {
pair.item = ExpandChain((Chain)pair.item);
} else {
//do nothing
}
} else if(pair.item instanceof PlusChain) {
Exception e = new Exception("ERROR 1: CheckChain");
e.printStackTrace();
} else { //item
//do nothing
}
}
chain = tmp;
} else if(chain instanceof MultiChain) {
MultiChain tmp = (MultiChain)chain.copy();
List<ItemPair> list = tmp.getAllItem();
for(int i=0;i<list.size();i++) {
ItemPair pair = list.get(i);
if(pair.item instanceof Chain)
pair.item = ReduceChain((Chain)pair.item);
if(pair.item instanceof PlusChain) {
if(Math.abs(pair.coef-1.0) < Constant.eps) {
Item tmp2 = tmp;
list.remove(i);
if(list.size() == 1) {
if(Math.abs(list.get(0).coef-1.0) < Constant.eps) {
tmp2 = list.get(0).item;
} else {
//do nothing
}
}
PlusChain pc = null;
if(tmp.length()>0) {
pc = PlusChainMultiItem((PlusChain) pair.item,tmp2);
} else {
pc = (PlusChain)pair.item;
pc.multiCoef(pair.coef);
}
return ExpandChain(pc);
} else if(pair.coef > 0 && Math.abs(Math.ceil(pair.coef)-pair.coef) < Constant.eps) {
//整数次幂转换成连乘形式
pair.coef = 1.0;
for(int j=1;j<=(int)pair.coef;j++) {
tmp.addItem(new ItemPair(1.0,pair.item));
}
return ExpandChain(tmp);
} else {
//do nothing
}
} else{
//do nothing
}
}
} else {
Exception e = new Exception("ERROR: Unsupported Chain Type");
e.printStackTrace();
}
chain.merge(true);
chain = ReduceChain(chain);
return chain;
}
}
| [
"[email protected]"
] | |
f80efc8757ddc2c0c724c5bf468b2ce57e4e3ec4 | 9d82dad9464214204b6940b08a72974f823eaf3d | /src/cursojava/classes/ClasseInicial.java | 4983f4e9a71d3dd4e244c4918f72e88c41a0ee72 | [] | no_license | cristianosantosoliveira/java-orientado-objeto | 5d705d4476031b09fa17627eb4dc3775fc387071 | 40d7b93da390042964577ab8a3120d7143cee424 | refs/heads/master | 2021-05-18T05:03:16.535061 | 2020-05-06T00:38:36 | 2020-05-06T00:38:36 | 251,123,907 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 6,407 | java | package cursojava.classes;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;
import javax.swing.JOptionPane;
import cursojava.auxiliar.FuncaoAutenticacao;
import cursojava.constantes.StatusAluno;
import cursojava.excecao.ExcecaoProcessarNota;
public class ClasseInicial {
public static void main(String[] args) {
try {
// lerArquivo();
String login = JOptionPane.showInputDialog("Informe o login");
String senha = JOptionPane.showInputDialog("Informe o senha");
if (new FuncaoAutenticacao(new Diretor(login, senha)).autenticar()) {
/*
* Trava o contrato para autorizar somente quem realmente tem o ontrato 100%
* legitmo, uma classe a mais que implementa PermitirAcesso além do secretário
*/
List<Aluno> alunos = new ArrayList<Aluno>();
/*
* E´uma lista que dentro dela temos uma chave que identifica uma sequencia de
* valores tambem
*/
HashMap<String, List<Aluno>> maps = new HashMap<String, List<Aluno>>();
for (int quantidade = 1; quantidade <= 1; quantidade++) {
String nome = JOptionPane.showInputDialog("Qual o nome do aluno " + quantidade + "? ");
String idade = JOptionPane.showInputDialog("Qual a idade? ");
// String DataNasc = JOptionPane.showInputDialog("Qual a data de nascimento? ");
// String rg = JOptionPane.showInputDialog("Qual o RG? ");
// String cpf = JOptionPane.showInputDialog("Qual o CPF? ");
// String nomeMae = JOptionPane.showInputDialog("Qual o nome da mãe? ");
// String nomePai = JOptionPane.showInputDialog("Qual o nome do pai? ");
// String dataMatricula = JOptionPane.showInputDialog("Qual a data da matricula? ");
// String serie = JOptionPane.showInputDialog("Qual a serie? ");
// String nomeEscola = JOptionPane.showInputDialog("Qual o nome da Escola? ");
Aluno aluno1 = new Aluno();
aluno1.setNome(nome);
aluno1.setIdade(Integer.valueOf(idade));
// aluno1.setDataNasc(DataNasc);
// aluno1.setRegistroGeral(rg);
// aluno1.setNumeroCpf(cpf);
// aluno1.setNomeMae(nomeMae);
// aluno1.setNomePai(nomePai);
// aluno1.setDataMatricula(dataMatricula);
// aluno1.setSerieMatriculado(serie);
// aluno1.setNomeEscola(nomeEscola);
for (int pos = 1; pos <= 1; pos++) {
String nomeDisciplina = JOptionPane.showInputDialog("Entre com nome da disciplina " + pos + "");
String notaDisciplina = JOptionPane.showInputDialog("Entre com nota da disciplina " + pos + "");
Disciplina disciplina = new Disciplina();
disciplina.setDisciplina(nomeDisciplina);
// disciplina.setNota(Double.valueOf(notaDisciplina));
aluno1.getDisciplinas().add(disciplina);
}
int opcao = JOptionPane.showConfirmDialog(null, "Deseja remover alguma disciplina? ");
if (opcao == 0) { // SIM = 0 NAO = 1
int continuarRemover = 0; // Opção de remoção de varias disciplinas
int posicao = 1;
while (continuarRemover == 0) {
String disciplinaRemover = JOptionPane.showInputDialog("Qual a disciplina 1,2,3,4?");
aluno1.getDisciplinas().remove(Integer.valueOf(disciplinaRemover).intValue() - posicao);
posicao++;
continuarRemover = JOptionPane.showConfirmDialog(null, "Continuar a remover? ");
}
}
alunos.add(aluno1);
}
maps.put(StatusAluno.APROVADO, new ArrayList<Aluno>());
maps.put(StatusAluno.REPROVADO, new ArrayList<Aluno>());
maps.put(StatusAluno.RECUPERACAO, new ArrayList<Aluno>());
for (Aluno aluno : alunos) { // Separado em Listas
if (aluno.getAlunoAprovados().equalsIgnoreCase(StatusAluno.APROVADO)) {
maps.get(StatusAluno.APROVADO).add(aluno);
} else if (aluno.getAlunoAprovados().equalsIgnoreCase(StatusAluno.RECUPERACAO)) {
maps.get(StatusAluno.RECUPERACAO).add(aluno);
} else if (aluno.getAlunoAprovados().equalsIgnoreCase(StatusAluno.REPROVADO)) {
maps.get(StatusAluno.REPROVADO).add(aluno);
}
}
System.out.println("---------------Lista dos aprovados-------------------");
for (Aluno aluno : maps.get(StatusAluno.APROVADO)) {
System.out.println("Nome: " + aluno.getNome());
System.out.println("Resultado " + aluno.getAlunoAprovados());
System.out.println("Media " + aluno.getMediaNota());
}
System.out.println("---------------Lista dos Reprovados-------------------");
for (Aluno aluno : maps.get(StatusAluno.REPROVADO)) {
System.out.println("Nome: " + aluno.getNome());
System.out.println("Resultado " + aluno.getAlunoAprovados());
System.out.println("Media " + aluno.getMediaNota());
}
System.out.println("---------------Lista dos Recuperação------------------");
for (Aluno aluno : maps.get(StatusAluno.RECUPERACAO)) {
System.out.println("Nome: " + aluno.getNome());
System.out.println("Resultado " + aluno.getAlunoAprovados());
System.out.println("Media " + aluno.getMediaNota());
}
} else {
JOptionPane.showMessageDialog(null, "Acesso não realizado! ");
}
} catch (NumberFormatException e) {
StringBuilder saida = new StringBuilder();
e.printStackTrace(); // Imprime o erro dentro do console do Java
System.out.println("Mensagem: " + e.getMessage());
for (int i = 0; i < e.getMessage().length(); i++) {
/* Mensagens de erro ou causa */
saida.append("\n Classe de erro: " + e.getStackTrace()[i].getClassName());
saida.append("\n Metodo com erro: " + e.getStackTrace()[i].getMethodName());
saida.append("\n Linha de erro: " + e.getStackTrace()[i].getLineNumber());
saida.append("\n Class: " + e.getClass());
}
JOptionPane.showMessageDialog(null, "Erro de conversão de numeros " + saida.toString());
} catch (NullPointerException e) { // Tratando erros especificos
JOptionPane.showMessageDialog(null, "Null Point Exception " + e.getClass());
} catch (Exception e) { // Tratando erros genericos
e.printStackTrace();
JOptionPane.showMessageDialog(null, "Erro da exceção customizada " + e.getClass().getName());
} finally {/* Sempre será executado ocorren01do erros ou não */
JOptionPane.showMessageDialog(null, "Thanks for studying Java");
// Aplicação sempre é usado quando se precisa executar um processo
// acontecendo erro ou não em um sistema
}
}
}
| [
"[email protected]"
] | |
61c653fa4a16593d937dceda2d86e16a3bb5b152 | dae8c2f3ba6042ba4a8ef6a1a2b75832c26e186c | /JAVA/Dia10-1prj/src/Directivo.java | d3ff47db37e8d47cfbc48db3991d9c3d4d4fcdac | [] | no_license | HectorEdgar/Universidad | acf97c233261648725c6311abaf876a05b3e1cbd | 6dee7f1bbe195eb5caf900766079e81c3b39dcca | refs/heads/master | 2022-03-03T11:53:23.250054 | 2019-06-03T04:20:38 | 2019-06-03T04:20:38 | 189,933,653 | 0 | 0 | null | 2019-10-31T16:17:58 | 2019-06-03T04:21:00 | Java | UTF-8 | Java | false | false | 616 | java | public class Directivo extends Empleado {
private static final long serialVersionUID = 883659372759003440L;
private String accion;
public Directivo(){
}
public String getAccion() {
return accion;
}
public void setAccion(String accion) {
this.accion = accion;
}
@Override
public String desplegarInformacion() {
return super.desplegarInformacion()+"\nAccion: "+ this.accion;
}
@Override
public String calcularSueldo(){
Double sumaSueldo=0.0;
sumaSueldo=Double.parseDouble(super.calcularSueldo())+Double.parseDouble(this.accion);
return String.valueOf(sumaSueldo);
}
} | [
"[email protected]"
] | |
8ac47ab78d143df7af57cb5a4bdb3e52cce3ba46 | a0cd546101594e679544d24f92ae8fcc17013142 | /refactorit-core/src/test/misc/jacks/jls/classes/field-declarations/initialization-of-fields/restrictions/T8323ifi3.java | f55db87adaf6083946a02bdf6d8c51aec1828d85 | [] | no_license | svn2github/RefactorIT | f65198bb64f6c11e20d35ace5f9563d781b7fe5c | 4b1fc1ebd06c8e192af9ccd94eb5c2d96f79f94c | refs/heads/master | 2021-01-10T03:09:28.310366 | 2008-09-18T10:17:56 | 2008-09-18T10:17:56 | 47,540,746 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 81 | java |
class T8323ifi3 {
int i = j += 1;
int j = 1;
}
| [
"l950637@285b47d1-db48-0410-a9c5-fb61d244d46c"
] | l950637@285b47d1-db48-0410-a9c5-fb61d244d46c |
4b68420f0de15b3df594ed174e8603944aa595d2 | 89723541f3a2cc7087d49dcee592694c5c0513c3 | /hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/api/RequestTypeEnum.java | 963f0788153fcafab4b8e6912e360136897ab5af | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | rkorytkowski/hapi-fhir | 7207ae68ff8ef6e876f53b51bbdbd0312ae0daa7 | 9f45c2bcfa00349ce17e191899581f4fc6e8c0d6 | refs/heads/master | 2021-07-13T01:06:12.674713 | 2020-06-16T09:11:38 | 2020-06-16T09:12:23 | 145,406,752 | 0 | 2 | Apache-2.0 | 2018-08-20T11:08:35 | 2018-08-20T11:08:35 | null | UTF-8 | Java | false | false | 807 | java | package ca.uhn.fhir.rest.api;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2018 University Health Network
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
public enum RequestTypeEnum {
CONNECT, DELETE, GET, OPTIONS, PATCH, POST, PUT, TRACE, TRACK, HEAD
}
| [
"[email protected]"
] | |
da9b01530347084a23a69db9230b11de04164ffc | f44ed4482fd1acad04741b76c5ee0622caac41fa | /16_ServidorConfiguracionDistribuida/src/main/java/com/atsistemas/controllers/HolaMundoController.java | 4288bebe631e02b97289e5b3843f207c7392f8d4 | [] | no_license | dalonsogz/cursoSpringAT | 3aab44789e79fac4e5432ada9eebc39671649313 | 14bdc5e8643f4a839606380dcd14000f3723b639 | refs/heads/master | 2021-10-27T14:24:16.590038 | 2019-04-17T21:00:52 | 2019-04-17T21:00:52 | 110,295,908 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 511 | java | package com.atsistemas.controllers;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RefreshScope
public class HolaMundoController {
@RequestMapping(path="/HolaMundo")
public String holaMundo(@Value("${message:hola!}") String mensaje) {
return mensaje;
}
}
| [
"[email protected]"
] | |
804dda6b131c8a6b3b7ac2919d0cfa62ee9a1693 | 93ec5bdf1e64516915a86557f5ca6fdec02ef609 | /mytest/Test.java | 8be4b0ede2c5101a59fd6cbf6f67fc615f2ea5b1 | [] | no_license | flozano/stupid-jdk-cert-issue | dcc560dc1093ec2e8c1863f344629781e6f4278c | 2ce67ce0223e826ba2f2c53bdc0fe4ebce3c68ee | refs/heads/master | 2020-03-11T09:28:40.960579 | 2018-04-17T13:57:16 | 2018-04-17T13:57:16 | 129,912,545 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 395 | java | package mytest;
import java.net.*;
public class Test {
public static void main(String[] argz) throws Exception {
URL url = new URL("https://maven.kii.com/artifactory/repo/org/springframework/spring-context/5.0.5.RELEASE/spring-context-5.0.5.RELEASE.jar");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
System.err.println("Result was "+con.getResponseCode() );
}
}
| [
"[email protected]"
] | |
d9a6f04fba2064c160f327d7be7861897c0ec513 | d6a06f00a438a6fa15212fcf519386fbc06891b1 | /AV1/src/main/java/fvs/edu/br/main/Av1Application.java | 23a157fc288bd3a34899febbbca390f1061a1087 | [] | no_license | natan20155/AV1 | b1a0e0a33b0176097a76d3771c4ee183365087fd | 1fff6f9490dddd104321a9e15befd6463b47d27d | refs/heads/master | 2020-03-29T20:17:56.447878 | 2018-09-25T18:27:33 | 2018-09-25T18:27:33 | 150,304,835 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | package fvs.edu.br.main;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Av1Application {
public static void main(String[] args) {
SpringApplication.run(Av1Application.class, args);
}
}
| [
"[email protected]"
] | |
da646f318c6b1faf979d5bd19940a77f47085623 | ea67a9d5f29c52141d5000d4a4ada02375d31b49 | /java/tb/common/inventory/InventoryRevolver.java | fe41df4bbc18a7bb843d64057d8f94529cd911f6 | [
"CC0-1.0",
"CC-BY-SA-4.0"
] | permissive | joutenchi/ThaumicBases | 947899d52f869effc0bca0d57445a5ed5c8906e9 | 6aab92667554511559366c7d3a3c9b78c5b4b79a | refs/heads/1.8 | 2020-03-31T09:15:16.220222 | 2016-02-23T18:56:32 | 2016-02-23T18:56:32 | 152,088,166 | 0 | 0 | CC0-1.0 | 2019-02-26T01:48:23 | 2018-10-08T13:51:46 | Java | UTF-8 | Java | false | false | 2,996 | java | package tb.common.inventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import thaumcraft.api.aspects.Aspect;
import thaumcraft.api.aspects.AspectList;
import thaumcraft.common.blocks.devices.BlockJarItem;
public class InventoryRevolver implements IInventory
{
public ItemStack[] inventory;
public Container revolverContainer;
public InventoryRevolver(Container revolver)
{
this.inventory = new ItemStack[1];
this.revolverContainer = revolver;
}
public int getSizeInventory()
{
return 1;
}
public ItemStack getStackInSlot(int slot)
{
return inventory[0];
}
public ItemStack decrStackSize(int slot, int amount)
{
if (inventory[0] != null)
{
if (inventory[0].stackSize <= amount)
{
ItemStack stk = inventory[0];
inventory[0] = null;
revolverContainer.onCraftMatrixChanged(this);
return stk;
}
ItemStack var3 = this.inventory[0].splitStack(amount);
if (inventory[0].stackSize == 0)
{
inventory[0] = null;
}
revolverContainer.onCraftMatrixChanged(this);
return var3;
}
return null;
}
public void setInventorySlotContents(int slot, ItemStack stack)
{
inventory[0] = stack;
revolverContainer.onCraftMatrixChanged(this);
}
public int getInventoryStackLimit()
{
return 1;
}
public boolean isUseableByPlayer(EntityPlayer player)
{
return true;
}
public boolean isItemValidForSlot(int slot, ItemStack jar)
{
if (jar != null && jar.getItem() instanceof BlockJarItem && jar.hasTagCompound())
{
AspectList aspects = ((BlockJarItem)jar.getItem()).getAspects(jar);
if (aspects != null && aspects.size() > 0 && aspects.getAmount(Aspect.AVERSION) > 0)
return true;
}
return false;
}
public String getInventoryName()
{
return "container.revolver";
}
public boolean hasCustomInventoryName()
{
return false;
}
public void openInventory(){}
public void closeInventory(){}
@Override
public void markDirty(){}
@Override
public String getName() {
return getInventoryName();
}
@Override
public boolean hasCustomName() {
return false;
}
@Override
public IChatComponent getDisplayName() {
return new ChatComponentText(getName());
}
@Override
public void openInventory(EntityPlayer player) {
}
@Override
public void closeInventory(EntityPlayer player) {
}
@Override
public int getField(int id) {
return 0;
}
@Override
public void setField(int id, int value) {
}
@Override
public int getFieldCount() {
return 0;
}
@Override
public void clear() {
inventory = new ItemStack[1];
}
@Override
public ItemStack removeStackFromSlot(int index) {
if (this.inventory[0] != null)
{
ItemStack stk = this.inventory[0];
this.inventory[0] = null;
return stk;
}
return null;
}
}
| [
"[email protected]"
] | |
c6f5318c58108a6d03c15557f0fdbb5410dd7f9d | 22c8ef7faa64135c4447ad2419a752ed5cffeaa2 | /app/src/main/java/com/example/byjuses/UI/MainActivity.java | bd4cd6871ab4b25a27dd5402a5a41e2818fa3492 | [] | no_license | jitheshkumar2708/ByJuses | 7677faff86fe23a1247b9d1ce75d05e6bd7264a0 | 848028be9da4e91e0d9cee55765d674efc0cbcc7 | refs/heads/main | 2023-04-24T09:06:15.127010 | 2021-05-09T21:57:12 | 2021-05-09T21:57:12 | 365,216,398 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,827 | java | package com.example.byjuses.UI;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
import com.example.byjuses.Adapter.RecyclerAdapter;
import com.example.byjuses.MyViewModel;
import com.example.byjuses.R;
import java.util.Objects;
public class MainActivity extends AppCompatActivity {
RecyclerView recyclerView;
RecyclerAdapter adapter;
MyViewModel mViewModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setHasFixedSize(true);
Toolbar toolbar = findViewById(R.id.toolbar);
TextView textView = findViewById(R.id.toolbar_title);
//To make Text Type as RobotoSlab-Bold
Typeface roboto = Typeface.createFromAsset(this.getAssets(),
"font/RobotoSlab-Bold.ttf");
textView.setTypeface(roboto);
setSupportActionBar(toolbar);
Objects.requireNonNull(getSupportActionBar()).setDisplayShowTitleEnabled(false);
adapter = new RecyclerAdapter();
recyclerView.setAdapter(adapter);
mViewModel = new ViewModelProvider(this).get(MyViewModel.class);
mViewModel.getNewsLiveData();
mViewModel.getAllNews().observe(this, newsModels -> {
if (!newsModels.isEmpty())
adapter.setList(newsModels, getApplicationContext());
});
}
} | [
"jithesh@1996"
] | jithesh@1996 |
46243094f3434ada0c006ca061d7101e9bdc6613 | 8074e94435b636c7ac4a3e8b6a8d42f59f946a4e | /app/src/androidTest/java/com/example/kh/message/ExampleInstrumentedTest.java | a0e1d9d98a4b38916427443db1c96c5dea6404ec | [] | no_license | zxvcvzx1994/BindToReoveService | 3c7d74984810a5cd2d975cdccc0249bf55802744 | a90c6801367d8ce72fd79b9e418f5269002f99ca | refs/heads/master | 2020-12-13T04:32:28.829132 | 2017-06-26T06:50:49 | 2017-06-26T06:50:49 | 95,417,161 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 748 | java | package com.example.kh.message;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.kh.message", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
2d899af8f25dd16418a225b141c30525af78dc1d | ffcb017ac021479328a0ac9d76384ca56a008c67 | /src/class4/boj9465/Boj9465_sh.java | 421b6c28be1b5b8f44935bcc698e98ef39ffcaf5 | [] | no_license | girawhale/Algo_study | 5b051777f4a5a97ed315ee214bf489c50e573d28 | bf307a665465427cfe33b0b2bb247be6737190c5 | refs/heads/master | 2023-02-17T14:16:44.867001 | 2021-01-18T08:22:12 | 2021-01-18T08:22:12 | 290,190,583 | 4 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,285 | java | package class4.boj9465;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Boj9465_sh {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
for (int tc = 1; tc <= T; tc++) {
int n = Integer.parseInt(br.readLine());
int[][] sticker = new int[2][];
for (int i = 0; i < 2; i++)
sticker[i] = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
int[][] dp = new int[2][n];
dp[0][0] = sticker[0][0];
dp[1][0] = sticker[1][0];
dp[0][1] = dp[1][0] + sticker[0][1];
dp[1][1] = dp[0][0] + sticker[1][1];
int ans = 0;
for (int i = 2; i < n; i++) {
dp[0][i] = sticker[0][i] + Math.max(dp[1][i - 1], Math.max(dp[0][i - 2], dp[1][i - 2]));
dp[1][i] = sticker[1][i] + Math.max(dp[0][i - 1], Math.max(dp[0][i - 2], dp[1][i - 2]));
ans = Math.max(ans, Math.max(dp[0][i], dp[1][i]));
}
System.out.println(ans);
}
}
}
| [
"choi1278!"
] | choi1278! |
cf8f2950d0ca7d1e6e5f2f1759430ebadbdf395b | 1fe1e59a3d27668d6c756bb4504cd88e0c584cc8 | /src/sk/clovece/Panacik.java | f66d5afd563d6601946d7a3f2cb18eb30ecfba08 | [] | no_license | Citronik/Java | cb7ea21847fd4f49d7633493d63358b85f2a8969 | de967a93484f2d1a20a098f13995c0ec5bcaced2 | refs/heads/master | 2023-04-30T16:20:28.155968 | 2020-05-05T16:36:15 | 2020-05-05T16:36:15 | 261,528,482 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,989 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package sk.clovece;
/**
*
* @author Filip Perďoch
*/
public class Panacik {
private boolean vDomceku;
private boolean vCieli;
private final String farba;
private Pohyb pohyb;
private int aktualnaPozicia;
private final int poziciaStartu;
public Panacik(String farba, int cisloPanacika, Pohyb pohyb) {
this.vDomceku = true;
this.vCieli = false;
this.farba = farba;
this.aktualnaPozicia = cisloPanacika;
this.pohyb = pohyb;
switch (this.farba) {
case ("Zlta"):
this.poziciaStartu = 10;
break;
case ("Zelena"):
this.poziciaStartu = 20;
break;
case ("Cervena"):
this.poziciaStartu = 30;
break;
default:
this.poziciaStartu = 0;
}
}
public String getFarba() {
return this.farba;
}
public boolean getVDomceku() {
return this.vDomceku;
}
public int getAktualnaPozicia() {
return this.aktualnaPozicia;
}
public void rozmiestniPanacikovDoDomceku() {
int posun = this.pohyb.getPozicieDomceku(this.farba);
this.aktualnaPozicia += posun;
}
public void skocSPanacikom(int oKolko) {
if (this.pohyb.mozeSkakat(this, oKolko)) {
this.aktualnaPozicia += oKolko;
//System.out.format("%d%n", this.aktualnaPozicia);
}
}
public void posunNaStart() {
this.vDomceku = false;
this.aktualnaPozicia = this.poziciaStartu;
}
public boolean jeVCieli() {
return this.aktualnaPozicia >= 39;
}
}
| [
"Filip Perďoch@DESKTOP-U4J4540"
] | Filip Perďoch@DESKTOP-U4J4540 |
f87d788ec4360825132ebfd42f39a4a9d0e2bc9a | c11f910e07e29a8fa14bbdbe173172bcc703d0c0 | /exercises/sublist/src/example/java/RelationshipComputer.java | 381272512c740ffa5cf9649964ef781a03b13d71 | [
"MIT"
] | permissive | jtigger/xjava | 11893534a0be5815d07c37375cb8281dfa65c2ff | 195a324a23a9aa9e4bdc7d4d6d79781e0103188e | refs/heads/master | 2021-01-12T22:30:29.791303 | 2017-04-24T16:02:25 | 2017-04-24T16:02:25 | 36,503,965 | 0 | 1 | null | 2015-05-29T12:48:22 | 2015-05-29T12:48:22 | null | UTF-8 | Java | false | false | 1,063 | java | import java.util.List;
final class RelationshipComputer<T extends Comparable> {
Relationship computeRelationship(final List<T> firstList, final List<T> secondList) {
if (firstList.equals(secondList)) return Relationship.EQUAL;
if (checkIfSublist(firstList, secondList)) return Relationship.SUBLIST;
if (checkIfSublist(secondList, firstList)) return Relationship.SUPERLIST;
return Relationship.UNEQUAL;
}
private boolean checkIfSublist(final List<T> firstList, final List<T> secondList) {
final int firstListSize = firstList.size();
final int secondListSize = secondList.size();
if (firstListSize > secondListSize) return false;
final int numberOfSublistCandidates = secondListSize - firstListSize + 1;
for (int startIndex = 0; startIndex < numberOfSublistCandidates; startIndex++) {
if (secondList.subList(startIndex, startIndex + firstListSize).equals(firstList)) {
return true;
}
}
return false;
}
}
| [
"[email protected]"
] | |
4ab6fddd54fd1241977864fa09ecf157073d8d76 | 250a605853e3b8e419870d7b46e3595a6d4cd6af | /src/animata/controls/ClockBobber.java | aca9e7e15e90414a123a5947174da48af594fb5c | [] | no_license | michaelforrest/animataplayback | c5bccc577a58f437af55c8a8399f86ba16fc09aa | ce605df0289796c160ce547b73ec650bae76930d | refs/heads/master | 2016-09-06T11:45:03.605369 | 2011-07-01T11:36:06 | 2011-07-01T11:36:06 | 107,934 | 5 | 1 | null | null | null | null | UTF-8 | Java | false | false | 709 | java | package animata.controls;
import java.util.Observable;
import java.util.Observer;
import animata.Animator;
import animata.Clock;
import animata.Controller;
public class ClockBobber implements Observer {
private Animator animator;
public ClockBobber(Clock clock) {
System.out.println("new clock bobber");
clock.addObserver(this);
animator = new Animator(0,this);
}
public void update(Observable o, Object arg) {
if(arg == Clock.CROTCHET){
animator.currentValue = 0;
animator.set((float)Math.PI,30);
}
if(o == animator) updateAnimation();
}
private void updateAnimation() {
Controller.getInstance().animateAllBones("crotchet", 1 - (float)Math.sin(animator.currentValue));
}
}
| [
"[email protected]"
] | |
20800c87274e27a07667c6de8547448b79595edb | e8b25fc8abaaf29401d74c2c727606575e882ede | /spring-yarn/spring-yarn-core/src/test/java/org/springframework/yarn/am/NMTokenCacheTests.java | c52c074b19b391ee0b0bb7ee4d21ea0b97621c98 | [
"Apache-2.0"
] | permissive | Nyaungbinhla/spring-hadoop | 32986498157aa1bbc668b3677c75702dbbe55afc | fdd75452015905d5882132f7b2b29078bfb48d76 | refs/heads/master | 2020-04-14T01:10:25.159186 | 2014-12-23T08:23:04 | 2014-12-23T08:23:04 | 28,798,430 | 1 | 0 | null | 2015-01-05T05:10:19 | 2015-01-05T05:10:18 | null | UTF-8 | Java | false | false | 3,114 | java | /*
* Copyright 2013 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.yarn.am;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.sameInstance;
import static org.junit.Assert.assertThat;
import java.nio.ByteBuffer;
import org.apache.hadoop.yarn.api.records.Token;
import org.apache.hadoop.yarn.client.api.NMTokenCache;
import org.junit.Test;
import org.springframework.yarn.support.compat.NMTokenCacheCompat;
/**
* Tests for Hadoops {@code NMTokenCache}. At a time writing this test hadoop
* vanilla 2.2.0 GA is using static methods in this class, however cloudera
* with 2.2.0-cdh5.0.0-beta-1 correctly modified this class with singleton
* pattern and removed other static methods. This class makes sure
* we work around this correctly.
*
* @author Janne Valkealahti
*
*/
public class NMTokenCacheTests {
@SuppressWarnings("static-access")
@Test
public void testTokenCacheGenericUsage() {
// cdh
// static org.apache.hadoop.yarn.client.api.NMTokenCache.getSingleton()
// void org.apache.hadoop.yarn.client.api.NMTokenCache.setNMToken(String, Token)
// vanilla
// static void org.apache.hadoop.yarn.client.api.NMTokenCache.setNMToken(String, Token)
NMTokenCache cache1 = NMTokenCacheCompat.getNMTokenCache();
NMTokenCache cache2 = NMTokenCacheCompat.getNMTokenCache();
cache1.setNMToken("nodeAddr1", new TestToken("kind1"));
cache2.setNMToken("nodeAddr2", new TestToken("kind2"));
assertThat(cache1.getNMToken("nodeAddr1").getKind(), is("kind1"));
assertThat(cache2.getNMToken("nodeAddr1").getKind(), is("kind1"));
assertThat(cache1.getNMToken("nodeAddr2").getKind(), is("kind2"));
assertThat(cache2.getNMToken("nodeAddr2").getKind(), is("kind2"));
assertThat(cache1, sameInstance(cache2));
assertThat(NMTokenCacheCompat.getNMTokenCache(), sameInstance(NMTokenCacheCompat.getNMTokenCache()));
}
private static class TestToken extends Token {
String kind;
public TestToken(String kind) {
this.kind = kind;
}
@Override
public ByteBuffer getIdentifier() {
return null;
}
@Override
public void setIdentifier(ByteBuffer identifier) {
}
@Override
public ByteBuffer getPassword() {
return null;
}
@Override
public void setPassword(ByteBuffer password) {
}
@Override
public String getKind() {
return kind;
}
@Override
public void setKind(String kind) {
this.kind = kind;
}
@Override
public String getService() {
return null;
}
@Override
public void setService(String service) {
}
}
}
| [
"[email protected]"
] | |
96ea8699b9844a328b05b944ccd394fea88c3ccc | 1246648bed63fac165b35aa2fe181adfec028291 | /src/main/java/com/gang/demo/pattern/Builder/Dictory.java | 2eaef27311cfe0393bdac802c6d91935565eee78 | [] | no_license | liyougang/degisn-pattern-demo | dbd2714148fb65fb37464928c087c35a9882ea2c | 77a9a3d5306cff5efade27490fc19df004f8a1d4 | refs/heads/master | 2023-05-12T20:56:34.055972 | 2019-07-28T09:00:07 | 2019-07-28T09:00:07 | 195,477,023 | 0 | 0 | null | 2023-05-09T18:09:29 | 2019-07-05T23:25:19 | Java | UTF-8 | Java | false | false | 450 | java | package com.gang.demo.pattern.Builder;
/**
* @author ligang
* @desc
* @date 2019/7/10上午7:23
**/
public class Dictory {
private Builder builder;
public Dictory(Builder builder){
this.builder = builder;
}
public void constract(){
builder.makeTitle("greeting");
builder.makeString("早上好");
builder.makeItem(new String[]{"晚上好", "晚安", "再见"});
builder.close();
}
}
| [
"[email protected]"
] | |
2bc8bcd35d0c14c1df9c5033581d2adb8f4e8d83 | 4d0f2d62d1c156d936d028482561585207fb1e49 | /Ma nguon/zcs-8.0.2_GA_5570-src/ZimbraServer/src/java/com/zimbra/cs/account/ldap/upgrade/BUG_60640.java | ddcdd803cfb8789b78360d73b8d7adfa455913ba | [] | no_license | vuhung/06-email-captinh | e3f0ff2e84f1c2bc6bdd6e4167cd7107ec42c0bd | af828ac73fc8096a3cc096806c8080e54d41251f | refs/heads/master | 2020-07-08T09:09:19.146159 | 2013-05-18T12:57:24 | 2013-05-18T12:57:24 | 32,319,083 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,322 | java | /*
* ***** BEGIN LICENSE BLOCK *****
* Zimbra Collaboration Suite Server
* Copyright (C) 2011 Zimbra, Inc.
*
* The contents of this file are subject to the Zimbra Public License
* Version 1.3 ("License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.zimbra.com/license.
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
* ***** END LICENSE BLOCK *****
*/
package com.zimbra.cs.account.ldap.upgrade;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.zimbra.common.service.ServiceException;
import com.zimbra.cs.account.Cos;
import com.zimbra.cs.account.Entry;
import com.zimbra.cs.account.Provisioning;
import com.zimbra.cs.account.Entry.EntryType;
import com.zimbra.cs.ldap.LdapClient;
import com.zimbra.cs.ldap.LdapServerType;
import com.zimbra.cs.ldap.LdapUsage;
import com.zimbra.cs.ldap.ZLdapContext;
public class BUG_60640 extends UpgradeOp {
private static final String[] ATTR_NAMES = new String[] {
Provisioning.A_zimbraPrefReadingPaneLocation,
Provisioning.A_zimbraPrefTasksReadingPaneLocation,
Provisioning.A_zimbraPrefBriefcaseReadingPaneLocation
};
private static final String OLD_VALUE = "bottom";
private static final String NEW_VALUE = "right";
@Override
void doUpgrade() throws ServiceException {
ZLdapContext zlc = LdapClient.getContext(LdapServerType.MASTER, LdapUsage.UPGRADE);
try {
doAllCos(zlc);
} finally {
LdapClient.closeContext(zlc);
}
}
@Override
Description getDescription() {
return new Description(this,
ATTR_NAMES,
new EntryType[] {EntryType.COS},
OLD_VALUE,
NEW_VALUE,
String.format("Upgrade attribute %s on all cos from \"%s\" to \"%s\"",
Arrays.deepToString(ATTR_NAMES), OLD_VALUE, NEW_VALUE));
}
private void doEntry(ZLdapContext zlc, Entry entry) throws ServiceException {
String entryName = entry.getLabel();
printer.println();
printer.println("------------------------------");
printer.format("Checking %s on cos %s\n", Arrays.deepToString(ATTR_NAMES), entryName);
Map<String, Object> attrs = new HashMap<String, Object>();
for (String attrName : ATTR_NAMES) {
String curValue = entry.getAttr(attrName, false);
if (OLD_VALUE.equals(curValue)) {
attrs.put(attrName, NEW_VALUE);
} else {
printer.println(
String.format(" Current value of %s on cos %s is \"%s\" - not changed",
attrName, entryName, curValue));
}
}
try {
modifyAttrs(zlc, entry, attrs);
} catch (ServiceException e) {
printer.printStackTrace(e);
}
}
private void doAllCos(ZLdapContext zlc) throws ServiceException {
List<Cos> coses = prov.getAllCos();
for (Cos cos : coses) {
doEntry(zlc, cos);
}
}
}
| [
"[email protected]@ec614674-f94a-24a8-de76-55dc00f2b931"
] | [email protected]@ec614674-f94a-24a8-de76-55dc00f2b931 |
b2b326a0674676b8dc60601f26838ace21af3f83 | 5362eaf064561939b7ee654c5e049f044aa27a04 | /Advergame/core/src/com/henrik/gdxFramework/core/AnimationUtils.java | bc5e40fb7cf93555455b85bfc4fa863690317e62 | [] | no_license | hkeeble/LincolnImpGame | ce7c5a12c7e519fa776837ae3bb0a93d83293fae | 9cae4bb339e204aadf4e00760a7c6209bd132510 | refs/heads/master | 2021-03-22T03:56:57.301227 | 2015-05-28T14:13:37 | 2015-05-28T14:13:37 | 35,378,201 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,690 | java | package com.henrik.gdxFramework.core;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import java.util.ArrayList;
/**
* Contains some helper methods for creating animations.
*/
public class AnimationUtils {
/**
* Create an animation.
* @param spriteSheet The sprite sheet for the animation.
* @param frameWidth The width of each frame.
* @param frameHeight The height of each frame.
* @param frameDuration The duration of each frame.
* @param playMode The playmode of the animation.
*/
public static Animation createAnimation(Texture spriteSheet, int frameWidth, int frameHeight, float frameDuration, Animation.PlayMode playMode) {
TextureRegion[] frames = createFrameList(spriteSheet, frameWidth, frameHeight);
Animation anim = new Animation(frameDuration, frames);
anim.setPlayMode(playMode);
return anim;
}
/**
* Use this function to break a spritesheet into a list of texture regions, for use in an animated decal.
* @param spriteSheet The sprite sheet to use.
* @param frameWidth The width of each frame.
* @param frameHeight The height of each frame.
*/
public static TextureRegion[] createFrameList(Texture spriteSheet, int frameWidth, int frameHeight) {
TextureRegion[][] tiles = TextureRegion.split(spriteSheet, frameWidth, frameHeight);
TextureRegion[] frames = new TextureRegion[tiles.length*tiles[0].length];
int index = 0;
for(int x = 0; x < tiles.length; x++) {
for(int y = 0; y < tiles[0].length; y++) {
frames[index] = tiles[x][y];
index++;
}
}
return frames;
}
/**
* Use this function to break a spritesheet into a series of texture regions, each one representing a direction of movement.
* @param spriteSheet The sprite sheet to use.
* @param frameWidth The width of each frame.
* @param frameHeight The height of each frame.
*/
public static ArrayList<TextureRegion[]> createSprite(Texture spriteSheet, int frameWidth, int frameHeight) {
ArrayList<TextureRegion[]> anims = new ArrayList<TextureRegion[]>();
TextureRegion[][] tiles = TextureRegion.split(spriteSheet, frameWidth, frameHeight);
for(int x = 0; x < tiles.length; x++) {
TextureRegion[] frames = new TextureRegion[tiles[x].length];
for(int y = 0; y < tiles[x].length; y++) {
frames[y] = tiles[x][y];
}
anims.add(frames);
}
return anims;
}
}
| [
"[email protected]"
] | |
1ce786a82560a2b1e89af5989cb01be1731230af | e884a5926910e72aa3b5021708c19b1866413299 | /e-commerce/src/main/java/br/univel/controller/CarrinhoController.java | 1411300c9b5102d0bef54171149f75b467b9b229 | [] | no_license | felipemk/e-commerce_Felipe | 4523d136964c9f76f5e64c117a485c1d51d8be81 | 6339e437a7106128f7f5d2718c19c39ea9bbc69e | refs/heads/master | 2021-01-10T11:28:31.266261 | 2015-12-10T22:55:59 | 2015-12-10T22:55:59 | 45,217,540 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,370 | java | package br.univel.controller;
import java.util.HashMap;
import javax.inject.Inject;
import br.univel.model.Produto;
import br.univel.model.Venda;
import br.univel.rest.ProdutoEndpoint;
import br.univel.rest.VendaEndpoint;
public class CarrinhoController {
@Inject
private Carrinho carrinho;
@Inject
private ProdutoEndpoint pe;
@Inject
private VendaEndpoint vendaEp;
public void addProduto(Produto produto) {
Object produtos;
ProdutoPedido pp = ((Object) produtos).get(produto.getId());
if (pp == null) {
pp = new ProdutoPedido();
pp.setProduto(produto);
pp.setPreco(produto.getPreco());
pp.addProduto();
} else {
pp.addProduto();
}
produtos.put(produto.getId(), pp);
}
public void finalizarPedido() {
Pedido pedido = new Pedido();
entityManager.persist(pedido);
for (ProdutoPedido produtoPedido : this.produtos.values()) {
produtoPedido.setProduto(entityManager.merge(produtoPedido
.getProduto()));
produtoPedido.setPedido(pedido);
entityManager.persist(produtoPedido);
}
limpaCarrinho();
}
public void removeProduto(Long id) {
produtos.remove(id);
}
public void limpaCarrinho() {
produtos = new HashMap<Long, ProdutoPedido>();
}
public void limpar() {
carrinho.limpar();
}
public void finalizar() {
Venda venda = new Venda();
venda.setProduto(carrinho.getProduto());
}
}
| [
"Felipe Mikael@felipe"
] | Felipe Mikael@felipe |
7ae9c4b28729f840dd3dd1d0519a0a3f96185735 | 4ca027c910a533904d3fe5688a2f63d512dd2956 | /src/test/java/com/pronoia/aries/blueprint/util/parser/ElementParserTestSupport.java | c79f57005fe2b1435379eded13b08a95c7c2dff7 | [
"Apache-2.0"
] | permissive | hqstevenson/aries-blueprint-util | 08d5a4d9681817a478980827aa31b88bfdabd227 | 0230429b3d1819f03e5e798a1d8e5ce775cfbcec | refs/heads/master | 2023-03-10T11:03:38.466614 | 2019-02-02T20:27:39 | 2019-02-02T20:27:39 | 123,951,223 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,074 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.pronoia.aries.blueprint.util.parser;
import com.pronoia.aries.blueprint.util.namespace.ElementDefinitionException;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.junit.Before;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
/**
* Tests for the class.
*/
public abstract class ElementParserTestSupport {
Element handledElement;
Element subElement;
@Before
public void setUp() throws Exception {
File fXmlFile = new File("src/test/resources/OSGI-INF/blueprint/simple-handler-blueprint.xml");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
handledElement = (Element) doc.getDocumentElement().getElementsByTagName("simple-handler").item(0);
subElement = (Element) doc.getDocumentElement().getElementsByTagName("sub-element").item(0);
}
} | [
"[email protected]"
] | |
b2fa4bd8fd7831d90774529f24bab48735ff8d52 | b0892475e38b8201a4a36be4d5acfcc67958b062 | /scheduler-engine/src/test/java/com/vizuri/patient/scheduler/SchedulerTest.java | 30025d212dc3f20168bde05d5c52a34af29e547e | [] | no_license | Vizuri/optimal-patient-scheduler | 4cf0c72bc6f569b1b592c68c28e79c8552cbc831 | 56fb6745d9a5c6252945cebf383896b08f56d46d | refs/heads/master | 2021-01-13T08:03:01.738933 | 2017-06-21T16:24:56 | 2017-06-21T16:24:56 | 95,024,038 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 12,485 | java | package com.vizuri.patient.scheduler;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.time.LocalDate;
import java.time.Month;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.optaplanner.core.api.solver.Solver;
import org.optaplanner.core.api.solver.SolverFactory;
import org.optaplanner.core.api.solver.event.BestSolutionChangedEvent;
import org.optaplanner.core.api.solver.event.SolverEventListener;
import org.optaplanner.core.config.solver.termination.TerminationCompositionStyle;
import org.optaplanner.core.config.solver.termination.TerminationConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.vizuri.patient.scheduler.model.AppointmentType;
import com.vizuri.patient.scheduler.model.Day;
import com.vizuri.patient.scheduler.model.Patient;
import com.vizuri.patient.scheduler.model.Physician;
import com.vizuri.patient.scheduler.model.TreatmentDays;
import com.vizuri.patient.scheduler.solver.AppointmentSolution;
import com.vizuri.patient.scheduler.solver.ConsultationEncounter;
import com.vizuri.patient.scheduler.solver.Encounter;
import com.vizuri.patient.scheduler.solver.TreatmentEncounter;
import com.vizuri.patient.scheduler.util.DataFactory;
public class SchedulerTest {
private static final transient Logger logger = LoggerFactory.getLogger(SchedulerTest.class);
public static final String SOLVER_CONFIG = "com/vizuri/patient/scheduler/consultationSchedulingSolverConfig.xml";
private static SolverFactory<AppointmentSolution> solverFactory;
@Before
public void reset() {
DataFactory.reset();
solverFactory = SolverFactory.createFromXmlResource(SOLVER_CONFIG);
}
@Test
public void testScheduler() {
logger.info("Test!");
}
@Test
public void testSolverNoMoves() {
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.buildTestSolutionA(solution, LocalDate.of(2017, Month.MARCH, 1), 3);
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
assertEquals("Expected no hard score", 0, bestSolution.getScore().getHardScore());
assertEquals("Expected no soft score", 0, bestSolution.getScore().getSoftScore());
}
@Test
public void testSolverSingleEncounter() {
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.buildTestSolutionA(solution, LocalDate.of(2017, Month.MARCH, 1), 3);
Patient patient = solution.getPatients().get(0);
DataFactory.generateSingleConsult(solution, patient);
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
int consultCount = 0;
for (TreatmentEncounter treatment : bestSolution.getTreatments()) {
if (treatment.getAppointment().getPatient().equals(patient)) {
logger.info("Treatment schedule:: " + treatment);
}
}
for (ConsultationEncounter encounter : bestSolution.getEncounters()) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT)) {
consultCount++;
logger.info("Consult details: " + encounter);
}
}
assertEquals("Expecting single consultation", 1, consultCount);
}
@Test
public void testSolverSingleEncounterTop10() {
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.buildTestSolutionA(solution, LocalDate.of(2017, Month.MARCH, 1), 3);
Patient patient = solution.getPatients().get(0);
for (int i = 0; i < 10; i++) {
DataFactory.generateSingleConsult(solution, patient);
}
Patient patientb = solution.getPatients().get(10);
for (int i = 0; i < 10; i++) {
DataFactory.generateSingleConsult(solution, patientb);
}
logger.info("Patient A: " + patient);
logger.info("Patient B: " + patientb);
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
int consultCount = 0;
for (TreatmentEncounter treatment : bestSolution.getTreatments()) {
if (treatment.getAppointment().getPatient().equals(patient)) {
logger.info("Treatment schedule:: " + treatment);
}
}
List<ConsultationEncounter> encounters = new ArrayList<ConsultationEncounter>();
encounters.addAll(bestSolution.getEncounters());
Collections.sort(encounters, Encounter.EncounterComparator);
for (ConsultationEncounter encounter : encounters) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT) &&
encounter.getAppointment().getPatient().equals(patient)) {
consultCount++;
logger.info("(A) Consult details: " + encounter);
}
}
for (ConsultationEncounter encounter : encounters) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT) &&
encounter.getAppointment().getPatient().equals(patientb)) {
consultCount++;
logger.info("(B) Consult details: " + encounter);
}
}
assertEquals("Expecting single consultation", 20, consultCount);
}
@Test
public void testSolverSinglePhysician() {
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.buildSinglePhysicianSolution(solution, LocalDate.of(2017, Month.MARCH, 1), 3);
Patient patient = solution.getPatients().get(0); // 2 appointments, same patient
DataFactory.generateSingleConsult(solution, patient);
DataFactory.generateSingleConsult(solution, patient);
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
int consultCount = 0;
for (TreatmentEncounter treatment : bestSolution.getTreatments()) {
if (treatment.getAppointment().getPatient().equals(patient)) {
logger.info("Treatment schedule:: " + treatment);
}
}
for (ConsultationEncounter encounter : bestSolution.getEncounters()) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT)) {
consultCount++;
logger.info("Consult details: " + encounter);
}
}
assertEquals("Expecting 2 consultation", 2, consultCount);
}
@Test
public void testSolver1Physician2Clinics() {
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.build1Physician2ClinicsSolution(solution, LocalDate.of(2017, Month.MARCH, 1), 3);
Patient patientA = solution.getPatients().get(0); // 2 appointments, same patient
DataFactory.generateSingleConsult(solution, patientA);
Patient patientB = null;
for (Patient patient : solution.getPatients()) {
if (!patient.getClinic().equals(patientA.getClinic()) && patient.getTreatmentDays().equals(patientA.getTreatmentDays())) {
patientB = patient;
DataFactory.generateSingleConsult(solution, patient);
break;
}
}
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
int consultCount = 0;
for (TreatmentEncounter treatment : bestSolution.getTreatments()) {
if (treatment.getAppointment().getPatient().equals(patientA) || treatment.getAppointment().getPatient().equals(patientB)) {
logger.info("Treatment schedule:: " + treatment);
}
}
for (ConsultationEncounter encounter : bestSolution.getEncounters()) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT)) {
consultCount++;
logger.info("Consult details: " + encounter);
}
}
assertEquals("Expecting 2 consultation", 2, consultCount);
solution.setEncounters(new ArrayList<ConsultationEncounter> ());
DataFactory.generateSingleConsult(solution, patientA);
patientB = null;
for (Patient patient : solution.getPatients()) {
if (patient.getClinic().equals(patientA.getClinic()) && patient.getTreatmentDays().equals(patientA.getTreatmentDays()) && patient.getTreatmentShift() != patientA.getTreatmentShift()) {
patientB = patient;
DataFactory.generateSingleConsult(solution, patient);
break;
}
}
solver.solve(solution);
bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
consultCount = 0;
for (TreatmentEncounter treatment : bestSolution.getTreatments()) {
if (treatment.getAppointment().getPatient().equals(patientA) || treatment.getAppointment().getPatient().equals(patientB)) {
logger.info("Treatment schedule:: " + treatment);
}
}
for (ConsultationEncounter encounter : bestSolution.getEncounters()) {
if (encounter.getAppointment().getType().equals(AppointmentType.CONSULT)) {
consultCount++;
logger.info("Consult details: " + encounter);
}
}
assertEquals("Expecting 2 consultation", 2, consultCount);
}
@Test
public void testSolverManyPhysician1Clinic() {
/*TerminationConfig terminationConfig = new TerminationConfig();
terminationConfig.setTerminationCompositionStyle(TerminationCompositionStyle.OR);
terminationConfig.setBestScoreLimit("0hard/0medium/-50soft");
terminationConfig.setMinutesSpentLimit(1L);
terminationConfig.setUnimprovedSecondsSpentLimit(30L);
solverFactory.getSolverConfig().setTerminationConfig(terminationConfig);*/
Solver<AppointmentSolution> solver = createSolver();
AppointmentSolution solution = new AppointmentSolution();
DataFactory.buildManyPhysician1ClinicSolution(solution, LocalDate.of(2017, Month.MARCH, 1), 4);
int maxAppointments = 5;
int appointmentCount = 0;
for (Patient patient : solution.getPatients()) {
if (patient.getTreatmentDays().equals(TreatmentDays.MWF) && appointmentCount < maxAppointments) {
DataFactory.generateSingleConsult(solution, patient);
appointmentCount++;
}
}
solver.solve(solution);
AppointmentSolution bestSolution = solver.getBestSolution();
logger.info("\nSolved Physician Scheduling Problem :\nBest score: " + bestSolution.getScore());
// Expecting no days with more than one physician
Map<Day, Physician> physicianTable = new HashMap<Day,Physician>();
Map<String, Set<Day>> shiftTable = new HashMap<String, Set<Day>>();
for (ConsultationEncounter encounter : bestSolution.getEncounters()) {
logger.info("Consultation: " + encounter);
if (encounter.getStartingTime() != null) {
Day currentDay = encounter.getStartingTime().getDay();
Physician currentPhysician = encounter.getPhysician();
String shiftKey = currentPhysician.getId() + "-" +currentDay.getWeekOfYear();
if (physicianTable.get(currentDay) == null) {
physicianTable.put(currentDay, currentPhysician);
} else {
assertEquals("Expecting same physician assigned each day", currentPhysician, physicianTable.get(currentDay));
}
if (shiftTable.get(shiftKey) == null) {
Set<Day> days = new HashSet<Day>();
days.add(currentDay);
shiftTable.put(shiftKey, days);
} else {
shiftTable.get(shiftKey).add(currentDay);
assertTrue("Expecting no more than 2 shifts per week per physician", 2 >= shiftTable.get(shiftKey).size());
}
} else {
logger.error("Unscheduled consultation: " + encounter);
}
}
}
protected Solver<AppointmentSolution> createSolver() {
Solver<AppointmentSolution> solver = solverFactory.buildSolver();
solver.addEventListener(new SolverEventListener<AppointmentSolution>() {
public void bestSolutionChanged(BestSolutionChangedEvent<AppointmentSolution> event) {
//if (event.isNewBestSolutionInitialized()) { //&& event.getNewBestSolution().getScore().isFeasible()) {
AppointmentSolution bestSolution = (AppointmentSolution) event.getNewBestSolution();
if (logger.isDebugEnabled()) {
logger.debug("Current best score: " + bestSolution.getScore());
}
//}
}
});
return solver;
}
}
| [
"[email protected]"
] | |
61d4e4ffe2fd083a6b1ac8dcb62ca1fb3ff21e8b | f55c886ae133243f81a2167eb1bd79b8ecdf27e7 | /crud-faces/src/main/java/org/manaty/model/user/Permission.java | 7494806743297acde69fd3651bc8ea3d5f96e459 | [] | no_license | czetsuya/crud-faces | d08cea9a965c42bb39acb84533579634975c29ea | 19ba24ea904598db36a80f61f221f89ba337f81a | refs/heads/master | 2018-12-29T17:02:17.975738 | 2014-01-30T05:45:47 | 2014-01-30T05:45:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,084 | java | /*
* (C) Copyright 2009-2013 Manaty SARL (http://manaty.net/) and contributors.
*
* Licensed under the GNU Public Licence, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.gnu.org/licenses/gpl-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.manaty.model.user;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
@Entity
@Table(name = "MEVEO_PERMISSION")
@SequenceGenerator(name = "ID_GENERATOR", sequenceName = "MEVEO_PERMISSION_SEQ")
public class Permission implements Serializable {
private static final long serialVersionUID = 5845753342866770498L;
@Id
@GeneratedValue(generator = "ID_GENERATOR")
@Column(name = "ID")
private Long id;
@Column(name = "RESOURCE", nullable = false)
private String resource;
@Column(name = "PERMISSION", nullable = false)
private String permission;
@Column(name = "name", nullable = false)
private String name;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
public String getPermission() {
return permission;
}
public void setPermission(String permission) {
this.permission = permission;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return "Permission [name=" + name + ", resource=" + resource
+ ", permission=" + permission + "]";
}
} | [
"[email protected]"
] | |
cbefd8ea6e9cbaf52e9c13e5c7689d235086a3ca | 7bfaace1baec0a2fc53b2be1780898c915e96294 | /src/main/java/com/example/demo/CallLogRestController.java | aab3926e3874e1034d430af828372906aa62cb4a | [] | no_license | shubhambansal/CallLogApi | d4d416ffe4b334063f755dceb34564c84c98a96d | 80f13f88a1849c135d734bde8765da813ec074b8 | refs/heads/master | 2023-04-23T15:41:15.950913 | 2021-05-12T23:15:45 | 2021-05-12T23:15:45 | 366,877,143 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,349 | java | package com.example.demo;
import com.example.demo.dto.request.CallLogRequest;
import com.example.demo.dto.response.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.*;
@RestController
@Slf4j
public class CallLogRestController {
private CallLogRequest currentOngoingCall;
private final List<CallLogResponse> callLogList = new ArrayList<>();
private int statusQueryCounter = 0;
@GetMapping
public ResponseEntity<ServicesResponse> getEndPoints() {
InetAddress inetAddress = null;
try {
inetAddress = InetAddress.getLocalHost();
System.out.println("IP Address:- " + inetAddress.getHostAddress());
System.out.println("Host Name:- " + inetAddress.getHostName());
} catch (UnknownHostException e) {
e.printStackTrace();
}
Services status = new Services("status", "http://" + inetAddress.getHostAddress() + ":8080/status");
Services log = new Services("log", "http://" + inetAddress.getHostAddress() + ":8080/log");
return ResponseEntity.ok(ServicesResponse.builder().start(new Date()).services(List.of(status, log)).build());
}
@GetMapping(value = "/status", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<CallStatusResponse> getCallStatus() {
CallStatusResponse dto = null;
if (currentOngoingCall != null) {
dto = new CallStatusResponse(true, currentOngoingCall.getNumber(), currentOngoingCall.getName());
//We also have to updated the number of times it's get queried while phone call was in progress
statusQueryCounter += 1;
}
return ResponseEntity.ok(dto);
}
@GetMapping(value = "/log", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<CallLogResponse>> getCallLog() {
return ResponseEntity.ok(callLogList);
}
@PostMapping(value = "/callStart", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ApiResponse> setCallStart(@RequestBody CallLogRequest request) {
if (currentOngoingCall != null) {
log.info("Rejecting Call start request from {}", request.getNumber());
return ResponseEntity.ok(new ApiResponse(true, HttpStatus.IM_USED.value(), "Another call is in progress!"));
}
currentOngoingCall = request;
return ResponseEntity.ok(new ApiResponse(true, HttpStatus.OK.value(), null));
}
@PutMapping(value = "/callEnd", produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ApiResponse> setCallEnd(@RequestBody CallLogRequest request) {
//If there is a ongoing request then only it make sense to remove the entry and add to a log
if (currentOngoingCall != null && request.getNumber().equals(currentOngoingCall.getNumber())) {
long duration = getTotalDuration(currentOngoingCall.getBeginning(), request.getEnd());
CallLogResponse logResponse = CallLogResponse.builder().beginning(request.getBeginning()).number(request.getNumber()).name(request.getName()).duration(duration).timesQueried(statusQueryCounter).build();
statusQueryCounter = 0; //Resetting the counter back so we can count again from fresh
callLogList.add(logResponse);
//Resetting it back
currentOngoingCall = null;
return ResponseEntity.ok(new ApiResponse(true, HttpStatus.OK.value(), null));
} else {
log.info("Rejecting Call end request from {}", request.getNumber());
return ResponseEntity.ok(new ApiResponse(true, HttpStatus.CONFLICT.value(), "Cannot end a call for now!"));
}
}
/**
* Fn to get difference between two given dates
*
* @param startDateTime
* @param endDateTime
* @return value in minutes
*/
private long getTotalDuration(long startDateTime, long endDateTime) {
long durationInMillis = endDateTime - startDateTime;
return durationInMillis / 1000;
}
}
| [
"[email protected]"
] | |
fe2df50d8db9faab101bed32f7e6304f44a58aac | 26205f50f907ffae2d67ce17c88059c5c05607ff | /bobdust.rpc.helloworld/src/bobdust/rpc/helloworld/Listener.java | 3fbf02143f8ace18268c6bbc31d89ace2a72b24e | [] | no_license | bobdust/RSucket | ef1c71bc577b2f98c7f2a81ab5502f9c23ff75e5 | ef81c471346956fbeca40f7dbf226bcd75db29e5 | refs/heads/master | 2020-11-30T15:08:07.171132 | 2014-08-12T08:19:34 | 2014-08-12T08:19:34 | 66,369,315 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 357 | java | package bobdust.rpc.helloworld;
import java.io.IOException;
import bobdust.sockets.*;
public class Listener {
public static void main(String[] args) throws IOException
{
Responder<GreetingAssistant> assistant = ResponderFactory.get(GreetingAssistantImpl.class, 1234);
assistant.start();
System.out.println("Greeting Assistant started.");
}
}
| [
"[email protected]"
] | |
ac10a926406f1dfd7747ebdb8aeeddbea6d061b8 | 7ea9839d07cb0771744021ad478fffdc89c28937 | /android/app/src/main/java/com/foodies/SplashActivity.java | a40155112584fb8eb2028740aa44d9bc74f90408 | [] | no_license | itssaurav/Foodies | 9a580e1e0e6e559b763462b77df2b57fbdaec366 | c8f30582c63742c6e97e87d49b548f0a6abdec02 | refs/heads/master | 2020-09-16T08:53:44.873329 | 2019-11-24T09:10:01 | 2019-11-24T09:10:01 | 223,718,136 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 458 | java | package com.foodies; // make sure this is your package name
import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class SplashActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
finish();
}
} | [
"[email protected]"
] | |
96ebb0177c2e925d76f298f434a12951750770c4 | 83cec781ac1876769f68b226ba6ab0b1d5d6061c | /src/Horoscopes.java | 4d6cf1e44c18339c80531ebd9d317ea40f5a46e9 | [] | no_license | League-Level0-Student/level-0-module-3-FordBravo29 | 1c3ece4ce6259c9f2e55af2a95e8837b55bae62e | ab02a0bb708f784603b4c769e50ad9c3e1572fb6 | refs/heads/master | 2020-05-05T11:52:29.285705 | 2019-07-14T17:53:16 | 2019-07-14T17:53:16 | 180,006,993 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 875 | java | import javax.swing.JOptionPane;
public class Horoscopes {
public static void main(String[] args) {
String hi =
JOptionPane.showInputDialog("What is your star sign");
if(hi.equals ("leo")) {
JOptionPane.showMessageDialog(null, "leo signs tend to like relaxation, preferably someplace warm and comfortable."
+ " Leo likes the big picture, not the small details and fine print. ");
}
if(hi.equals("scorpio")) {
JOptionPane.showMessageDialog(null, "Scorpio signs are not fearful individuals,"
+ " often trying things that others would not attempt. "
+ "This is because they most often become self-aware at an earlier age than most other signs.");
}
if(hi.equals("cancer")) {
JOptionPane.showMessageDialog(null, "Cancer is a water sign which means that they have a deep,"
+ " mysterious side to them that can also be gentle and nurturing.");
}
}
}
| [
"[email protected]"
] | |
0c55a52e171a43c240a9cb9b49b1abce95de7b7c | 83b9cdf1d697afaa54e9606963ae9c951cf38c05 | /FSC-Destiny/jboss/server/destiny/work/jboss.web/localhost/_/org/apache/jsp/cataloging/basesearchresults_jsp.java | 1367070d3ef042c2957af81c80a86e60fcb6b6f0 | [] | no_license | mikeleonfsc/destinydocker | 2cdac594a27b9489d9246fc004005ab6cb8231cb | bd3abde9e8daaf1de10f201aa9dd135b29c6c2ef | refs/heads/master | 2021-04-28T23:52:36.941265 | 2017-01-04T13:51:45 | 2017-01-04T13:51:45 | 77,727,464 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,617 | java | package org.apache.jsp.cataloging;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import com.follett.fsc.destiny.client.cataloging.servlet.*;
import com.follett.fsc.common.MessageHelper;
import com.follett.fsc.common.LocaleHelper;
public final class basesearchresults_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent {
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.List _jspx_dependants;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody;
private org.apache.jasper.runtime.TagHandlerPool _005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor;
private javax.el.ExpressionFactory _el_expressionfactory;
private org.apache.AnnotationProcessor _jsp_annotationprocessor;
public Object getDependants() {
return _jspx_dependants;
}
public void _jspInit() {
_005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
_jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName());
}
public void _jspDestroy() {
_005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody.release();
_005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor.release();
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n");
out.write("\r\n\r\n\r\n\r\n\r\n");
String parentFormName = (String)request.getAttribute("parentFormName");
BaseSearchResultsForm form = (BaseSearchResultsForm)request.getAttribute(parentFormName);
String viewTypeElem = "";
if (form.isElementaryMode() && !CategorySearchResultsForm.FORM_NAME.equals(parentFormName)) {
viewTypeElem = "viewTypeElem";
}
// if the user klicked the keywords tab, we're going to show the tabbed result list
// even if it is empty
if (request.getAttribute("MyKeywordList") != null || form.isUserClickedKeywordsTab()) {
int itemsInList = form.getTotalCount();
if ( itemsInList > 0 || form.isUserClickedKeywordsTab() || request.getAttribute(AdvancedSearchForm.SHOW_RESULTS_ALWAYS) != null) {
out.write("\r\n<div id=\"viewTypeElem\" class=\"");
out.print(viewTypeElem);
out.write("\">\r\n");
// html:hidden
org.apache.struts.taglib.html.HiddenTag _jspx_th_html_005fhidden_005f0 = (org.apache.struts.taglib.html.HiddenTag) _005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody.get(org.apache.struts.taglib.html.HiddenTag.class);
_jspx_th_html_005fhidden_005f0.setPageContext(_jspx_page_context);
_jspx_th_html_005fhidden_005f0.setParent(null);
// /cataloging/basesearchresults.jsp(33,0) name = property type = null reqTime = true required = true fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_html_005fhidden_005f0.setProperty(BaseSearchResultsForm.FIELD_DO_NOT_SAVE_SEARCH_HISTORY );
int _jspx_eval_html_005fhidden_005f0 = _jspx_th_html_005fhidden_005f0.doStartTag();
if (_jspx_th_html_005fhidden_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody.reuse(_jspx_th_html_005fhidden_005f0);
return;
}
_005fjspx_005ftagPool_005fhtml_005fhidden_005fproperty_005fnobody.reuse(_jspx_th_html_005fhidden_005f0);
out.write("\r\n<input type=\"image\" src=\"/images/icons/general/spacer.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"\" value=\"true\" name=\"");
out.print(form.BUTTON_TRAP_ENTER_KEY);
out.write("\">\r\n\r\n<table width=\"95%\" id=\"");
out.print(form.TABLE_KEYWORD_RESULTS);
out.write("\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\r\n <tr>\r\n <td colspan=\"1\">\r\n ");
// base:outlinedTableAndTabsWithinThere
com.follett.fsc.destiny.client.common.jsptag.OutlinedTableAndTabsWithinThereTag _jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0 = (com.follett.fsc.destiny.client.common.jsptag.OutlinedTableAndTabsWithinThereTag) _005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor.get(com.follett.fsc.destiny.client.common.jsptag.OutlinedTableAndTabsWithinThereTag.class);
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setPageContext(_jspx_page_context);
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setParent(null);
// /cataloging/basesearchresults.jsp(39,12) name = tabs type = null reqTime = true required = true fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setTabs(form.getTabs() );
// /cataloging/basesearchresults.jsp(39,12) name = selectedTab type = null reqTime = true required = true fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setSelectedTab(form.getSelectedTab() );
// /cataloging/basesearchresults.jsp(39,12) name = tabClass type = null reqTime = true required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setTabClass(form.getTabClass() );
// /cataloging/basesearchresults.jsp(39,12) name = borderColor type = null reqTime = true required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setBorderColor("#c0c0c0");
// /cataloging/basesearchresults.jsp(39,12) name = width type = null reqTime = true required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setWidth("100%");
// /cataloging/basesearchresults.jsp(39,12) name = cellpadding type = null reqTime = true required = false fragment = false deferredValue = false deferredMethod = false expectedTypeName = null methodSignature = null
_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.setCellpadding(0);
int _jspx_eval_base_005foutlinedTableAndTabsWithinThere_005f0 = _jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.doStartTag();
if (_jspx_eval_base_005foutlinedTableAndTabsWithinThere_005f0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\r\n ");
if (BookSeriesResultsForm.FORM_NAME.equals(parentFormName)) {
out.write("\r\n ");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/cataloging/basebookseriesresultsdata.jsp", out, true);
out.write("\r\n ");
} else {
if (form.isElementaryMode() && !CategorySearchResultsForm.FORM_NAME.equals(parentFormName)) {
out.write("\r\n ");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/cataloging/basesearchresultsdata_elem.jsp", out, true);
out.write("\r\n ");
} else {
out.write("\r\n ");
org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "/cataloging/basesearchresultsdata.jsp", out, true);
out.write("\r\n ");
}
}
out.write("\r\n ");
int evalDoAfterBody = _jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.doAfterBody();
if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN)
break;
} while (true);
}
if (_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) {
_005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor.reuse(_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0);
return;
}
_005fjspx_005ftagPool_005fbase_005foutlinedTableAndTabsWithinThere_005fwidth_005ftabs_005ftabClass_005fselectedTab_005fcellpadding_005fborderColor.reuse(_jspx_th_base_005foutlinedTableAndTabsWithinThere_005f0);
out.write("\r\n </td>\r\n </tr>\r\n</table>\r\n</div>\r\n");
}
}
out.write('\r');
out.write('\n');
} catch (Throwable t) {
if (!(t instanceof SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try { out.clearBuffer(); } catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}
| [
"[email protected]"
] | |
3a7019f9d3bf7888d64e2953bad106dac553f2f9 | 7aaf9080945e7213f6046e9d8473140781aef846 | /023-Array/src/Main.java | a53cda5e1aa3aba7d9e5015099bdb69266598043 | [] | no_license | AyakaYasuda/m0921-Java-Collection | ee33bb0ad2ae5fc1819cd186603275e052301736 | 6309d9c1ca7a5a516e8b994a1f6d3cd05df70dc5 | refs/heads/main | 2023-08-15T04:24:10.827455 | 2021-10-19T21:46:31 | 2021-10-19T21:46:31 | 419,099,728 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 523 | java |
public class Main {
public static void main(String[] args) {
int[] array = {5,6,7,8};
display(array);
// int[] array2 = new int[10];
// array2[5] = 10;
// array2[9] = 99;
// System.out.println(array2[1]);
float[] floatArr = {0.0f, 1.2f, 3.4f};
/* Syntax for loop of array
for(data_type variable: array) {
// body of the loop
}
*/
for(float i: floatArr) {
System.out.println(i);
}
}
static void display(int a[]) {
for(float i: a) {
System.out.println(i);
}
}
}
| [
"[email protected]"
] | |
ccb40d8e1737f6b6d400aab56677fed62e3bc8ea | f4268dc3c647dbdf60f2ac036e4c1f55a54329ae | /EVM/src/EVM_1309/BallotPaperScreen.java | 4ee960ddae59023caf11cef8f7d45a26d13d5bc5 | [] | no_license | MiracleT/1309EVM_aftertest | 66a0c7cd6629accce259aedd4db421c6013f1180 | 10841852fe372f3091a8179078a4e0846c6188ff | refs/heads/master | 2021-01-01T19:19:47.757509 | 2015-07-19T15:39:16 | 2015-07-19T15:39:16 | 39,338,795 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 918 | java | package EVM_1309;
import java.util.ArrayList;
public class BallotPaperScreen {
static ArrayList <String> candidatePaper = new ArrayList<String>();
void setUpScreen(){
candidatePaper.add("LOTUS");
candidatePaper.add("HAND");
candidatePaper.add("DOLL");
System.out.println("Ballot paper placed and aligned");
seal();
}
private void seal() {
System.out.println("SEALED");
}
public void viewSymbol() {
CandidateLamp cll =new CandidateLamp();
CandidateButton cb =new CandidateButton();
// Command c=new On();
System.out.println("\n");
for(int i=0;i<candidatePaper.size();i++){
System.out.print(candidatePaper.get(i));
cll.enable("Lamp"+i);
cb.enable("button"+i);
//c.working(lf.getType("candidateLamp"));
}
}
public String getSymbol(int i){
//System.out.print(candidatePaper.get(i));
return candidatePaper.get(i);
}
}
| [
"[email protected]"
] | |
ccaba31afb6e44da489897063df26011fcf08518 | 12ec68d1e39864360788eba9ef5e1392c729b6ae | /dagger-core-web/src/main/java/com/springdagger/core/web/exception/RedupSubmitException.java | 7d0cec9d3fc901c5712a83887b07cbc10c37d61a | [] | no_license | qiaomu1102/dagger-tool | 60cb22ce41291004b38d16756422a2d92f567a83 | 07edc1861d67e92d68f9f85a59c46b7c8f869411 | refs/heads/master | 2023-03-11T13:17:16.019489 | 2021-02-26T08:47:38 | 2021-02-26T08:47:38 | 307,282,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package com.springdagger.core.web.exception;
import com.springdagger.core.tool.api.BaseException;
import com.springdagger.core.tool.api.IResultCode;
import com.springdagger.core.tool.api.ResultCode;
/**
* @author: qiaomu
* @date: 2020/12/9 10:39
* @Description: TODO
*/
public class RedupSubmitException extends BaseException {
public RedupSubmitException() {
iResultCode = ResultCode.REDUP_SUBMIT_ERROR;
}
public RedupSubmitException(String message) {
super(message);
iResultCode = ResultCode.REDUP_SUBMIT_ERROR;
}
public RedupSubmitException(IResultCode iResultCode) {
super(iResultCode);
}
public RedupSubmitException(IResultCode iResultCode, String message) {
super(iResultCode, message);
}
}
| [
"[email protected]"
] | |
979fa76b11176f9522353e4b739510cd6ce4fc70 | 8b40d8fb82d67f5bc25e34da19e86c53a99494d9 | /src/main/java/sk/fei/stuba/oop/zadanie3/config/UUIDconverterConfig.java | 53153eb02baf140c9dcea8b2c2af0165d671daa7 | [] | no_license | onibaku789/youmakemyheartbleed | 6512649110cdb0b4548b2e8876c37691f213992d | b03df29e3a105e79244b27d1338b2bc39e844aa1 | refs/heads/master | 2022-09-05T23:10:08.593440 | 2020-05-24T11:16:02 | 2020-05-24T11:16:02 | 266,132,871 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 855 | java | package sk.fei.stuba.oop.zadanie3.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.converter.Converter;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import sk.fei.stuba.oop.zadanie3.model.contract.nonlifeinsurance.EstateType;
import java.util.UUID;
@Configuration
@EnableWebMvc
public class UUIDconverterConfig implements WebMvcConfigurer {
@Override
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new Converter<String, UUID>() {
@Override
public UUID convert(String UUIDString) {
return UUID.fromString(UUIDString);
}
});
}
}
| [
"[email protected]"
] | |
102ad95d404ea9133c905b25dcf5ffd3ecec6286 | 2ac49f0355769fb7c42c70eab4730ba8c7453cd1 | /src/constants/ServerConstants.java | a2ec4504098897437aa72ccc7fca1e5c3068b53c | [] | no_license | v3921358/ParadiseMS_v1.23 | 053ce8168261548c915d994e30edb01e5d43227b | 048014af2bba237f866c618f10718ea523ddf711 | refs/heads/master | 2022-09-11T11:50:23.441707 | 2018-07-12T05:39:42 | 2018-07-12T05:39:42 | 267,604,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,727 | java | package constants;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.util.LinkedList;
import java.util.List;
import javax.management.MBeanServer;
import javax.management.ObjectName;
public class ServerConstants implements ServerConstantsMBean {
public static boolean TESPIA = false; // true = uses GMS test server, for MSEA it does nothing though
public static final byte[] Gateway_IP = (GameConstants.GMS ? (TESPIA ? new byte[]{(byte) 0x3F, (byte) 0xFB, (byte) 0xD9, (byte) 0x72} : new byte[]{(byte) 0x8, (byte) 0x1F, (byte) 0x62, (byte) 0x34}) : new byte[]{(byte) 0xCB, (byte) 0xBC, (byte) 0xEF, (byte) 0x52});
public static final short MAPLE_VERSION = (short) (GameConstants.GMS ? (TESPIA ? 10 : 103) : 123);
public static final String MAPLE_PATCH = GameConstants.GMS ? "1" : "1";
public static boolean Use_Fixed_IV = false; // true = disable sniffing, false = server can connect to itself
public static boolean Use_Localhost = false; // true = packets are logged, false = others can connect to server
public static final String MASTER_LOGIN = "", MASTER = "", MASTER2 = "";
public static final long number1 = (142449577 + 753356065 + 611816275297389857L);
public static final long number2 = 1877319832;
public static final long number3 = 202227478981090217L;
public static final List<String> eligibleIP = new LinkedList<String>(), localhostIP = new LinkedList<String>();
/*
* Specifics which job gives an additional EXP to party
* returns the percentage of EXP to increase
*/
public static byte Class_Bonus_EXP(final int job) {
switch (job) {
case 501:
case 530:
case 531:
case 532:
case 2300:
case 2310:
case 2311:
case 2312:
case 3100:
case 3110:
case 3111:
case 3112:
case 800:
case 900:
case 910:
return 10;
}
return 0;
}
public static enum PlayerGMRank {
NORMAL('@', 0),
DONATOR('#', 1),
SUPERDONATOR('$', 2),
INTERN('%', 3),
GM('!', 4),
SUPERGM('!', 5),
ADMIN('!', 6);
private char commandPrefix;
private int level;
PlayerGMRank(char ch, int level) {
commandPrefix = ch;
this.level = level;
}
public char getCommandPrefix() {
return commandPrefix;
}
public int getLevel() {
return level;
}
}
public static enum CommandType {
NORMAL(0),
TRADE(1);
private int level;
CommandType(int level) {
this.level = level;
}
public int getType() {
return level;
}
}
public static boolean isEligibleMaster(final String pwd, final String sessionIP) {
return pwd.equals(MASTER) && isEligible(sessionIP);
}
public static boolean isEligible(final String sessionIP) {
return eligibleIP.contains(sessionIP.replace("/", ""));
}
public static boolean isEligibleMaster2(final String pwd, final String sessionIP) {
return pwd.equals(MASTER2) && isEligible(sessionIP);
}
public static boolean isIPLocalhost(final String sessionIP) {
return !Use_Fixed_IV && localhostIP.contains(sessionIP.replace("/", ""));
}
static {
localhostIP.add("203.116.196.8"); // Ares
localhostIP.add("203.188.239.82"); // Artemis
localhostIP.add("8.31.98.52");
localhostIP.add("8.31.98.53");
localhostIP.add("8.31.98.54");
}
public static ServerConstants instance;
public void run() {
updateIP();
}
public void updateIP() {
eligibleIP.clear();
final String[] eligibleIPs = {"203.188.239.82", "127.0.0.1", "203.116.196.8"}; //change IPs here; can be no-ip or just raw address
for (int i = 0; i < eligibleIPs.length; i++) {
try {
eligibleIP.add(InetAddress.getByName(eligibleIPs[i]).getHostAddress().replace("/", ""));
} catch (Exception e) {
}
}
}
public static void registerMBean() {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try {
instance = new ServerConstants();
instance.updateIP();
mBeanServer.registerMBean(instance, new ObjectName("constants:type=ServerConstants"));
} catch (Exception e) {
System.out.println("Error registering Shutdown MBean");
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
f1329d947083866d75290efd890a5aa28ee14173 | 5cf5d9e4286aaa40b879af0ab3eeb5294ffbf60a | /src/main/java/com/listing/springbatch/job/ExamResultItemProcessor.java | 80de6d70cd33acd8d8010c128bd170e23df16375 | [] | no_license | agrawaljay/SpringBatchFileToCsv | 008881e03290a3f322edd9fa87667f81a8d562d8 | d6cf87c1ccde0a90f138c953cb378a54d581d9e5 | refs/heads/master | 2020-03-28T11:12:17.739860 | 2018-09-22T07:50:16 | 2018-09-22T07:50:16 | 148,188,269 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 547 | java | package com.listing.springbatch.job;
import org.springframework.batch.item.ItemProcessor;
import com.listing.springbatch.model.ExamResult;
public class ExamResultItemProcessor implements ItemProcessor<ExamResult, ExamResult> {
@Override
public ExamResult process(ExamResult result) throws Exception {
System.out.println("Processing Itemresult :"+result);
//Write logic to get the data from manager and create a new pojo or update the existing one.
result.setCheck(1);
// TODO Auto-generated method stub
return result;
}
}
| [
"[email protected]"
] | |
98cb40230cd6d200c09b15138c9d8475adc63ae1 | 5261d0eb44f542fa8cfd3401a177011ce4ac8eeb | /src/main/java/com/lst/controller/DemoController.java | b7708340335359289944f5582c8901334bd6b267 | [] | no_license | cky13858806884/demo | 18e99c0ce977a7ce67da4cf1cd1347b8e57efb1c | 918f51eff4e0eca9f055f4204cd95e7706e28b33 | refs/heads/master | 2020-03-07T08:44:49.419578 | 2018-03-29T08:06:04 | 2018-03-29T08:06:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,243 | java | package com.lst.controller;
import com.lst.redis.RedisService;
import com.lst.service.DemoService;
import com.lst.utils.PageData;
import com.lst.utils.Result;
import com.lst.utils.ResultsFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
@RestController
public class DemoController{
@Autowired
private DemoService demoService;
@Autowired
private RedisService redisService;
@GetMapping(value = "demo")
public Result demo(){
Result result = new Result();
String demo = demoService.demo();
result.data = demo;
return result;
}
@GetMapping(value = "demo1")
public Result demo1() throws Exception{
Result result = new Result();
DCDemo javacTest = new DCDemo();
String input_str = DCDemo.eval("input_str");
result.data = input_str;
return result;
}
@RequestMapping("/redis/set")
public Result redisSet(@RequestParam("value")String value){
redisService.set("name", value);
return ResultsFactory.buildSuccess("q2");
}
@RequestMapping("/redis/get")
public Result redisGet(){
String name = redisService.get("name");
return ResultsFactory.buildSuccess(name);
}
@RequestMapping("/demo/pageData")
public String pageData(){
PageData pageData =new PageData();
pageData.put("channelid",1);
pageData.put("userid",1);
List list = new ArrayList();
list.add("userid");
list.add("channelid");
pageData.put("list",list);
return demoService.demoPageData(pageData);
}
public static void main(String[] args) {
for (int i = 0 ; i<100 ; i++){
Integer flag = new Random().nextInt(999999);
if (flag < 100000)
{
flag += 100000;
}
System.out.println(flag.toString());
}
}
}
| [
"[email protected]"
] | |
e1762f5f742e47c33f550152f1e40567b790e2ca | dbb15fac18fde7b652bc5d1b230e2a9223f5e47e | /BeginnersMethod.java | 53f121873ba4aa9c542ce0e1b0e8e696337c75d5 | [] | no_license | rafikatten29/rubik-cube | e253d824fd90ef641f9c09138e97117b963dd96f | a9ec168144b022e74b68dfb173aebdfc1c9855b2 | refs/heads/main | 2023-03-02T07:46:13.676062 | 2021-02-08T18:29:21 | 2021-02-08T18:29:21 | 337,118,588 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 43,204 | java |
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class BeginnersMethod extends Cube {
private final int WINDOW_WIDTH = 1200;
private final int WINDOW_HEIGHT = 800;
private JFrame frame;
private JPanel topRubik;
private JPanel bottomRubik;
private JPanel frontRubik;
private JPanel backRubik;
private JPanel leftRubik;
private JPanel rightRubik;
private JPanel colours;
private JPanel buttons;
private JPanel empty1;
private JPanel empty2;
private JPanel empty3;
private JPanel empty4;
private JButton[][][] cubeButtons = new JButton [6][3][3];
private JRadioButton white;
private JRadioButton blue;
private JRadioButton red;
private JRadioButton green;
private JRadioButton orange;
private JRadioButton yellow;
private ButtonGroup buttonGroup;
private JButton random;
private JButton answer;
private JTextArea display;
JScrollPane scrollPane;
public BeginnersMethod () {
super();
}
public void buildInterface () {
frame = new JFrame ();
frame.setTitle("Beginners Method");
frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GridLayout grid = new GridLayout(3, 4, 30 , 30);
frame.setLayout(grid);
topRubik = new JPanel();
bottomRubik = new JPanel();
frontRubik = new JPanel();
backRubik = new JPanel();
leftRubik = new JPanel();
rightRubik = new JPanel();
colours = new JPanel();
buttons = new JPanel();
empty1 = new JPanel ();
empty2 = new JPanel ();
empty3 = new JPanel ();
empty4 = new JPanel ();
topRubik.setLayout(new GridLayout(3,3));
bottomRubik.setLayout(new GridLayout(3,3));
frontRubik.setLayout(new GridLayout(3,3));
backRubik.setLayout(new GridLayout(3,3));
leftRubik.setLayout(new GridLayout(3,3));
rightRubik.setLayout(new GridLayout(3,3));
colours.setLayout(new GridLayout(3,2));
for (int i = 0; i < cube.length; i++)
for (int j = 0; j < cube[i].length; j++)
for (int k = 0; k < cube[i][j].length; k++)
cubeButtons[i][j][k] = new JButton ();
cubeButtons[0][1][1].setBackground(Color.white);
cubeButtons[1][1][1].setBackground(Color.blue);
cubeButtons[2][1][1].setBackground(Color.red);
cubeButtons[3][1][1].setBackground(Color.green);
cubeButtons[4][1][1].setBackground(Color.orange);
cubeButtons[5][1][1].setBackground(Color.yellow);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
topRubik.add(cubeButtons[0][j][k]);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
bottomRubik.add(cubeButtons[5][j][k]);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
frontRubik.add(cubeButtons[4][j][k]);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
backRubik.add(cubeButtons[2][j][k]);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
leftRubik.add(cubeButtons[1][j][k]);
for (int j = 0; j < cube[0].length; j++)
for (int k = 0; k < cube[0][j].length; k++)
rightRubik.add(cubeButtons[3][j][k]);
white = new JRadioButton("White");
blue = new JRadioButton("Blue");
red = new JRadioButton("Red");
green = new JRadioButton("Green");
orange = new JRadioButton("Orange");
yellow = new JRadioButton("Yellow");
buttonGroup = new ButtonGroup();
buttonGroup.add(white);
buttonGroup.add(blue);
buttonGroup.add(red);
buttonGroup.add(green);
buttonGroup.add(orange);
buttonGroup.add(yellow);
colours.add(white);
colours.add(blue);
colours.add(red);
colours.add(green);
colours.add(orange);
colours.add(yellow);
random = new JButton("Random");
answer = new JButton("Solve");
buttons.add(random);
buttons.add(answer);
Font font = new Font("Arial", Font.PLAIN, 12);
display = new JTextArea("Solution:", 10, 20);
display.setFont(font);
display.setLineWrap(true);
display.setWrapStyleWord(true);
scrollPane = new JScrollPane(display);
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
empty2.add(scrollPane);
for (int i = 0; i < cube.length; i++)
for (int j = 0; j < cube[i].length; j++)
for (int k = 0; k < cube[i][j].length; k++)
if (j != 1 || k != 1)
cubeButtons[i][j][k].addActionListener(new ButtonListener ());
random.addActionListener(new ButtonListener ());
answer.addActionListener(new ButtonListener ());
frame.add(empty1);
frame.add(topRubik);
frame.add(empty2);
frame.add(empty3);
frame.add(leftRubik);
frame.add(frontRubik);
frame.add(rightRubik);
frame.add(backRubik);
frame.add(empty4);
frame.add(bottomRubik);
frame.add(colours);
frame.add(buttons);
frame.pack();
frame.setVisible(true);
}
/*
This method is called to start search
*/
public void solve () {
if (this.checkCube()) {
layerOne();
layerTwo();
layerThree();
}
}
/*
This method solves first layer
*/
public void layerOne () {
whiteCross();
whiteCorners();
}
/*
This method solves white cross
*/
public void whiteCross () {
int [] whiteBlue = edge(1,2);
whiteBlue(whiteBlue);
int [] whiteRed = edge(1,3);
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
whiteRed = edge(1,3);
whiteRed(whiteRed);
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
int [] whiteGreen = edge(1,4);
whiteGreen(whiteGreen);
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
int [] whiteOrange = edge(1,5);
whiteOrange(whiteOrange);
}
/*
This method places white blue edge in correct position
*/
public void whiteBlue (int [] position) {
if (position[0] != 0 || position[1] != 1 || position[2] != 0) {
if (position[0] == 0) {
if (position[2] == 2)
moveGenerator(8);
else if (position[1] == 0)
moveGenerator(9);
else
moveGenerator(7);
}
else if (position[0] == 5) {
if (position[2] == 2)
moveGenerator(17);
else if (position[1] == 0) {
moveGenerator(10);
moveGenerator(17);
} else if (position[1] == 2) {
moveGenerator(12);
moveGenerator(17);
} else {
moveGenerator(11);
moveGenerator(17);
}
}
else if (position[0] == 4 && position[2] == 0)
moveGenerator(18);
else if (position[0] == 2 && position[2] == 2)
moveGenerator(16);
else if (position[0] == 4) {
if (position[1] == 0) {
moveGenerator(3);
moveGenerator(18);
} else if (position[1] == 2) {
moveGenerator(1);
moveGenerator(18);
} else {
moveGenerator(2);
moveGenerator(18);
}
} else if (position[0] == 2) {
if (position[1] == 0) {
moveGenerator(4);
moveGenerator(16);
} else if (position[1] == 2) {
moveGenerator(6);
moveGenerator(16);
} else {
moveGenerator(5);
moveGenerator(16);
}
} else if (position[0] == 3) {
if (position[1] == 0) {
moveGenerator(15);
moveGenerator(1);
moveGenerator(12);
moveGenerator(17);
}
else if (position[1] == 2) {
moveGenerator(13);
moveGenerator(1);
moveGenerator(12);
moveGenerator(17);
}
else if (position[2] == 2) {
moveGenerator(14);
moveGenerator(1);
moveGenerator(12);
moveGenerator(17);
}
else if (position[2] == 0) {
moveGenerator(1);
moveGenerator(12);
moveGenerator(17);
}
} else {
if (position[1] == 0) {
moveGenerator(16);
moveGenerator(3);
moveGenerator(12);
}
else if (position[1] == 2) {
moveGenerator(16);
moveGenerator(4);
moveGenerator(10);
}
else if (position[2] == 0) {
moveGenerator(4);
moveGenerator(10);
} else if (position[2] == 2) {
moveGenerator(3);
moveGenerator(12);
}
moveGenerator(17);
}
}
}
/*
This method places white red edge in correct position
*/
public void whiteRed (int [] position) {
if (position[0] != 0 || position[1] != 1 || position[2] != 0) {
if (position[0] == 0) {
if (position[1] == 0) {
moveGenerator(5);
moveGenerator(10);
moveGenerator(17);
}
else {
moveGenerator(14);
moveGenerator(11);
moveGenerator(17);
}
}
else if (position[0] == 5) {
if (position[2] == 2)
moveGenerator(17);
else if (position[1] == 0) {
moveGenerator(10);
moveGenerator(17);
} else if (position[1] == 2) {
moveGenerator(12);
moveGenerator(17);
} else {
moveGenerator(11);
moveGenerator(17);
}
}
else if (position[0] == 4 && position[2] == 0)
moveGenerator(18);
else if (position[0] == 2 && position[2] == 2)
moveGenerator(16);
else if (position[0] == 4) {
if (position[1] == 2) {
moveGenerator(1);
moveGenerator(18);
moveGenerator(3);
} else {
moveGenerator(2);
moveGenerator(18);
moveGenerator(2);
}
} else if (position[0] == 2) {
if (position[1] == 0) {
moveGenerator(4);
moveGenerator(16);
} else if (position[1] == 2) {
moveGenerator(6);
moveGenerator(16);
} else {
moveGenerator(5);
moveGenerator(16);
}
} else if (position[0] == 3) {
if (position[1] == 0) {
moveGenerator(15);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
moveGenerator(17);
}
else if (position[1] == 2) {
moveGenerator(13);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
moveGenerator(17);
}
else if (position[2] == 2) {
moveGenerator(14);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
moveGenerator(17);
}
else if (position[2] == 0) {
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
moveGenerator(17);
}
} else {
if (position[1] == 0) {
moveGenerator(16);
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
else if (position[1] == 2) {
moveGenerator(16);
moveGenerator(4);
moveGenerator(10);
}
else if (position[2] == 0) {
moveGenerator(4);
moveGenerator(10);
} else if (position[2] == 2) {
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
moveGenerator(17);
}
}
}
/*
This method places white green edge in correct position
*/
public void whiteGreen (int [] position) {
if (position[0] != 0 || position[1] != 1 || position[2] != 0) {
if (position[0] == 0) {
moveGenerator(5);
moveGenerator(10);
moveGenerator(17);
}
else if (position[0] == 5) {
if (position[2] == 2)
moveGenerator(17);
else if (position[1] == 0) {
moveGenerator(10);
moveGenerator(17);
} else if (position[1] == 2) {
moveGenerator(12);
moveGenerator(17);
} else {
moveGenerator(11);
moveGenerator(17);
}
}
else if (position[0] == 4 && position[2] == 0)
moveGenerator(18);
else if (position[0] == 2 && position[2] == 2)
moveGenerator(16);
else if (position[0] == 4) {
if (position[1] == 2) {
moveGenerator(1);
moveGenerator(18);
moveGenerator(3);
} else {
moveGenerator(2);
moveGenerator(18);
moveGenerator(2);
}
} else if (position[0] == 2) {
if (position[1] == 0) {
moveGenerator(4);
moveGenerator(16);
} else if (position[1] == 2) {
moveGenerator(6);
moveGenerator(16);
} else {
moveGenerator(5);
moveGenerator(16);
}
} else if (position[0] == 3) {
if (position[1] == 2) {
moveGenerator(15);
moveGenerator(6);
moveGenerator(13);
moveGenerator(10);
moveGenerator(17);
}
else if (position[2] == 2) {
moveGenerator(6);
moveGenerator(10);
moveGenerator(17);
}
else if (position[2] == 0) {
moveGenerator(14);
moveGenerator(6);
moveGenerator(14);
moveGenerator(10);
moveGenerator(17);
}
} else {
if (position[1] == 0) {
moveGenerator(16);
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
else if (position[1] == 2) {
moveGenerator(16);
moveGenerator(4);
moveGenerator(10);
}
else if (position[2] == 0) {
moveGenerator(4);
moveGenerator(10);
} else if (position[2] == 2) {
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
moveGenerator(17);
}
}
}
/*
This method places white orange edge in correct position
*/
public void whiteOrange (int [] position) {
if (position[0] != 0 || position[1] != 1 || position[2] != 0) {
if (position[0] == 5) {
if (position[2] == 2)
moveGenerator(17);
else if (position[1] == 0) {
moveGenerator(10);
moveGenerator(17);
} else if (position[1] == 2) {
moveGenerator(12);
moveGenerator(17);
} else {
moveGenerator(11);
moveGenerator(17);
}
}
else if (position[0] == 4 && position[2] == 0)
moveGenerator(18);
else if (position[0] == 2 && position[2] == 2)
moveGenerator(16);
else if (position[0] == 4) {
if (position[1] == 2) {
moveGenerator(1);
moveGenerator(18);
moveGenerator(3);
} else {
moveGenerator(2);
moveGenerator(18);
moveGenerator(2);
}
} else if (position[0] == 2) {
if (position[1] == 0) {
moveGenerator(4);
moveGenerator(16);
moveGenerator(6);
} else if (position[1] == 2) {
moveGenerator(6);
moveGenerator(16);
moveGenerator(4);
} else {
moveGenerator(5);
moveGenerator(16);
moveGenerator(5);
}
} else if (position[0] == 3) {
if (position[1] == 2) {
moveGenerator(15);
moveGenerator(6);
moveGenerator(10);
moveGenerator(17);
moveGenerator(4);
moveGenerator(13);
}
else if (position[2] == 2) {
moveGenerator(6);
moveGenerator(10);
moveGenerator(4);
moveGenerator(17);
}
else if (position[2] == 0) {
moveGenerator(14);
moveGenerator(6);
moveGenerator(10);
moveGenerator(17);
moveGenerator(12);
moveGenerator(4);
moveGenerator(14);
}
} else {
if (position[1] == 0) {
moveGenerator(16);
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
else if (position[1] == 2) {
moveGenerator(16);
moveGenerator(4);
moveGenerator(10);
moveGenerator(6);
}
else if (position[2] == 0) {
moveGenerator(4);
moveGenerator(10);
moveGenerator(6);
} else if (position[2] == 2) {
moveGenerator(3);
moveGenerator(12);
moveGenerator(1);
}
moveGenerator(17);
}
}
}
/*
This method solves the white corners
*/
public void whiteCorners () {
int [] whiteGreenRed = corner(1,4,3);
if (whiteGreenRed[0] == 0 || (whiteGreenRed[0] != 5 && whiteGreenRed[1] == 0))
bringDownCorner(whiteGreenRed, 1);
else if (whiteGreenRed[0] == 5)
bringUpCorner(whiteGreenRed, 1);
else
rightTopCorner(whiteGreenRed);
moveGenerator(20);
int [] whiteRedBlue = corner(1,3,2);
if (whiteRedBlue[0] == 0 || (whiteRedBlue[0] != 5 && whiteRedBlue[1] == 0))
bringDownCorner(whiteRedBlue, 2);
else if (whiteRedBlue[0] == 5)
bringUpCorner(whiteRedBlue, 2);
else
rightTopCorner(whiteRedBlue);
moveGenerator(20);
int [] whiteBlueOrange = corner(1,2,5);
if (whiteBlueOrange[0] == 0 || (whiteBlueOrange[0] != 5 && whiteBlueOrange[1] == 0))
bringDownCorner(whiteBlueOrange, 3);
else if (whiteBlueOrange[0] == 5)
bringUpCorner(whiteBlueOrange, 3);
else
rightTopCorner(whiteBlueOrange);
moveGenerator(20);
int [] whiteOrangeGreen = corner(1,5,4);
if (whiteOrangeGreen[0] == 0 || (whiteOrangeGreen[0] != 5 && whiteOrangeGreen[1] == 0))
bringDownCorner(whiteOrangeGreen, 4);
else if (whiteOrangeGreen[0] == 5)
bringUpCorner(whiteOrangeGreen, 4);
else
rightTopCorner(whiteOrangeGreen);
}
/*
This method brings down a white corner to the bottom layer
*/
public void bringDownCorner (int [] position, int cornerNum) {
if (position[0] != 0 || position[1] != 2 || position[2] != 2) {
if (position[0] == 0) {
if (position[1] == 0 && position[2] == 0) {
moveGenerator(18);
moveGenerator(10);
moveGenerator(16);
} else if (position[1] == 0 && position[2] == 2) {
moveGenerator(13);
moveGenerator(12);
moveGenerator(15);
} else if (position[1] == 2 && position[2] == 0) {
moveGenerator(16);
moveGenerator(10);
moveGenerator(18);
}
} else {
if (position[0] == 1 && position[1] == 0 && position[2] == 0) {
moveGenerator(18);
moveGenerator(12);
moveGenerator(16);
} else if (position[0] == 1 && position[1] == 0 && position[2] == 2) {
moveGenerator(16);
moveGenerator(11);
moveGenerator(18);
} else if (position[0] == 2 && position[1] == 0 && position[2] == 0) {
moveGenerator(6);
moveGenerator(12);
moveGenerator(4);
} else if (position[0] == 2 && position[1] == 0 && position[2] == 2) {
moveGenerator(4);
moveGenerator(10);
moveGenerator(6);
} else if (position[0] == 3 && position[1] == 0 && position[2] == 0) {
moveGenerator(15);
moveGenerator(12);
moveGenerator(13);
} else if (position[0] == 3 && position[1] == 0 && position[2] == 2) {
moveGenerator(13);
moveGenerator(11);
moveGenerator(15);
} else if (position[0] == 4 && position[1] == 0 && position[2] == 0) {
moveGenerator(3);
moveGenerator(11);
moveGenerator(1);
} else {
moveGenerator(1);
moveGenerator(10);
moveGenerator(3);
}
}
if (cornerNum == 1) {
int[] whiteGreenRed = corner(1, 4, 3);
rightTopCorner(whiteGreenRed);
} else if (cornerNum == 2) {
int[] whiteRedBlue = corner(1, 3, 2);
rightTopCorner(whiteRedBlue);
} else if (cornerNum == 3) {
int[] whiteBlueOrange = corner(1, 2, 5);
rightTopCorner(whiteBlueOrange);
} else if (cornerNum == 4) {
int[] whiteOrangeGreen = corner(1, 5, 4);
rightTopCorner(whiteOrangeGreen);
}
}
}
/*
This method brings up a white corner piece that is on the yellow side
facing downwards so that the white face in on another cube face
*/
public void bringUpCorner (int [] position, int cornerNum) {
if (position[1] == 0 && position[2] == 0) {
moveGenerator(12);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else if (position[1] == 0 && position[2] == 2) {
moveGenerator(11);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else if (position[1] == 2 && position[2] == 0) {
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else {
moveGenerator(10);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
if (cornerNum == 1) {
int [] whiteGreenRed = corner(1,4,3);
rightTopCorner(whiteGreenRed);
}
else if (cornerNum == 2) {
int [] whiteRedBlue = corner(1,3,2);
rightTopCorner(whiteRedBlue);
}
else if (cornerNum == 3) {
int[] whiteBlueOrange = corner(1, 2, 5);
rightTopCorner(whiteBlueOrange);
}
else if (cornerNum == 4) {
int[] whiteOrangeGreen = corner(1, 5, 4);
rightTopCorner(whiteOrangeGreen);
}
}
/*
This method insets white corner piece on top right hand corner
*/
public void rightTopCorner (int [] position) {
if (position[2] == 0) {
if (position[0] == 1) {
moveGenerator(12);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
}
else if (position[0] == 2) {
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
}
else if (position[0] == 3) {
moveGenerator(10);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
}
else {
moveGenerator(11);
moveGenerator(1);
moveGenerator(12);
moveGenerator(3);
}
}
else if (position[2] == 2){
if (position[0] == 1) {
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else if (position[0] == 2) {
moveGenerator(10);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else if (position[0] == 3) {
moveGenerator(11);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
else {
moveGenerator(12);
moveGenerator(15);
moveGenerator(10);
moveGenerator(13);
}
}
}
/*
This method solves the second layer
*/
public void layerTwo () {
System.out.println(checkCube());
moveGenerator(19);
moveGenerator(19); // The cube should have yellow side facing up and orange side in front
System.out.println(checkCube());
layerTwoPieces();
}
/*
This method iterates through the layer two pieces trying to find a piece
that is in the correct postion for the algorithm. If no pieces are found
but the layer two has not been solved then it deals with the piece which
has a wrong orientation.
*/
public void layerTwoPieces () {
int[] orangeGreen = null;
int[] orangeBlue = null;
int[] redBlue = null;
int[] redGreen = null;
int count = 0;
int corrections = 0;
boolean og = false;
boolean ob = false;
boolean rb = false;
boolean rg = false;
while (count < 4 && (!og || !ob || !rb || !rg)) {
orangeGreen = edge(5, 4);
if (layerTwoCorrectPositon(orangeGreen)) {
System.out.println("Testing orange green.");
System.out.println("Orange green start position is "+orangeGreen[0]+""+orangeGreen[1]+orangeGreen[2]);
layerTwoAlgorithm(orangeGreen, false, 1);
orangeGreen = edge(5, 4);
System.out.println("Orange green end position is "+orangeGreen[0]+""+orangeGreen[1]+orangeGreen[2]);
og = true;
corrections++;
}
orangeBlue = edge(5, 2);
if (layerTwoCorrectPositon(orangeBlue)) {
System.out.println("Testing orange blue.");
System.out.println("Orange blue start position is "+orangeBlue[0]+""+orangeBlue[1]+orangeBlue[2]);
layerTwoAlgorithm(orangeBlue, true, 2);
orangeBlue = edge(5, 2);
System.out.println("Orange blue end position is "+orangeBlue[0]+""+orangeBlue[1]+orangeBlue[2]);
ob = true;
corrections++;
}
moveGenerator(20);
moveGenerator(20);
redBlue = edge(3, 2);
if (layerTwoCorrectPositon(redBlue)) {
System.out.println("Testing red blue.");
System.out.println("Red blue start position is "+redBlue[0]+""+redBlue[1]+redBlue[2]);
layerTwoAlgorithm(redBlue, false, 3);
redBlue = edge(3, 2);
System.out.println("Red blue end position is "+redBlue[0]+""+redBlue[1]+redBlue[2]);
rb = true;
corrections++;
}
redGreen = edge(3, 4);
if (layerTwoCorrectPositon(redGreen)) {
System.out.println("Testing red green.");
System.out.println("Red green start position is "+redGreen[0]+""+redGreen[1]+redGreen[2]);
layerTwoAlgorithm(redGreen, true, 4);
redGreen = edge(3, 4);
System.out.println("Red green end position is "+redGreen[0]+""+redGreen[1]+redGreen[2]);
rg = true;
corrections++;
}
moveGenerator(20);
moveGenerator(20);
if (corrections > 0) {
count++;
System.out.println("The count is "+count);
corrections = 0;
}
else {
System.out.println("Entered the replacement section");
int[] replacement = {4, 0, 1};
if (!og) {
layerTwoAlgorithm(replacement, false, 1);
} else if (!ob) {
layerTwoAlgorithm(replacement, true, 2);
} else if (!rb) {
moveGenerator(20);
moveGenerator(20);
layerTwoAlgorithm(replacement, false, 3);
moveGenerator(20);
moveGenerator(20);
} else if (!rg) {
moveGenerator(20);
moveGenerator(20);
layerTwoAlgorithm(replacement, true, 4);
moveGenerator(20);
moveGenerator(20);
}
}
}
}
/*
This method checks that the layer two piece is in the correct position
for the algorithm
*/
public boolean layerTwoCorrectPositon (int [] position) {
if (position[0] == 0)
return true;
else if (position[1] == 0) {
return true;
}
return false;
}
/*
This method peforms the algorithm for the layer two piece
*/
public void layerTwoAlgorithm (int [] position, boolean right, int side) {
int [] colourPosition = null;
if (!right) {
if (position[0] != 0) {
if (position[0] == 4) {
moveGenerator(9);
}
else if (position[0] == 1) {
moveGenerator(8);
}
else if (position[0] == 2) {
moveGenerator(7);
}
moveGenerator(18);
moveGenerator(7);
moveGenerator(16);
moveGenerator(7);
moveGenerator(1);
moveGenerator(9);
moveGenerator(3);
}
else if(position[0] == 0) {
if (side == 1) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20); // Turn so that green side is facing at front
colourPosition = edge(4, 5); // switch which colour is searched for in edge
layerTwoAlgorithm(colourPosition, true, 1);
moveGenerator(20);
}
else if (side == 3) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20); // Turn so that blue side is facing at front
colourPosition = edge(2, 3);
layerTwoAlgorithm(colourPosition, true, 3);
moveGenerator(20);
}
}
}
else if (right) {
if (position[0] != 0) {
if (position[0] == 4) {
moveGenerator(7);
} else if (position[0] == 3) {
moveGenerator(8);
} else if (position[0] == 2) {
moveGenerator(9);
}
moveGenerator(13);
moveGenerator(9);
moveGenerator(15);
moveGenerator(9);
moveGenerator(3);
moveGenerator(7);
moveGenerator(1);
} else if (position[0] == 0) {
if (side == 2) {
moveGenerator(20);
colourPosition = edge(2, 5);
layerTwoAlgorithm(colourPosition, false, 2);
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
} else if (side == 4) {
moveGenerator(20);
colourPosition = edge(4, 3);
layerTwoAlgorithm(colourPosition, false, 4);
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
}
}
}
/*
This method performs solves the third layer
*/
public void layerThree () {
yellowCross();
yellowCorners();
orientCorners();
orientCross();
}
/*
This method solves the yellow cross
*/
public void yellowCross () {
int state = analysisYellow(); // Dot is state 1, L shape is, rod is state 3, and cross is state 4
if (state == 1) {
yellowCrossAlgorithm2();
yellowCross();
}
else if (state == 2) {
yellowCrossAlgorithm1();
yellowCross();
}
else if (state == 3) {
yellowCrossAlgorithm2();
}
}
/*
This method returns an integer indicating what is on the yellow side
1 - yellow dot
2 - yellow 'L' shape
3 = yellow rod
4 - yellow cross
The algorithm depends on this analsis. See Ruwix website for
explanation of how the algorithm works
*/
public int analysisYellow () {
if (cube[0][1][0] != 6 && cube[0][0][1] != 6 && cube[0][1][2] != 6 && cube[0][2][1] != 6) {
return 1;
}
else if (cube[0][1][0] == 6 && cube[0][0][1] == 6 && cube[0][1][2] != 6 && cube[0][2][1] != 6) {
return 2;
}
else if (cube[0][1][0] != 6 && cube[0][0][1] == 6 && cube[0][1][2] == 6 && cube[0][2][1] != 6) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
return 2;
}
else if (cube[0][1][0] != 6 && cube[0][0][1] != 6 && cube[0][1][2] == 6 && cube[0][2][1] == 6) {
moveGenerator(20);
moveGenerator(20);
return 2;
}
else if (cube[0][1][0] == 6 && cube[0][0][1] != 6 && cube[0][1][2] != 6 && cube[0][2][1] == 6) {
moveGenerator(20);
return 2;
}
else if (cube[0][1][0] == 6 && cube[0][1][2] == 6 && (cube[0][0][1] != 6 || cube[0][2][1] != 6)) {
return 3;
}
else if (cube[0][0][1] == 6 && cube[0][2][1] == 6 && (cube[0][1][0] != 6 || cube[0][1][2] != 6 )) {
moveGenerator(20);
return 3;
}
else if (cube[0][1][0] == 6 && cube[0][0][1] == 6 && cube[0][1][2] == 6 && cube[0][2][1] == 6) {
return 4;
}
return 0;
}
/*
This performs the first algorithm of the yellow cross
*/
public void yellowCrossAlgorithm1 () {
moveGenerator(1);
moveGenerator(7);
moveGenerator(13);
moveGenerator(9);
moveGenerator(15);
moveGenerator(3);
}
/*
This performs the second algorithm of the yellow cross
*/
public void yellowCrossAlgorithm2 () {
moveGenerator(1);
moveGenerator(13);
moveGenerator(7);
moveGenerator(15);
moveGenerator(9);
moveGenerator(3);
}
/*
This method places the yellow corners in
*/
public void yellowCorners () {
if (!yellowCornerFinished()) {
rotateCubeForYellowCorners();
moveGenerator(13);
moveGenerator(7);
moveGenerator(15);
moveGenerator(7);
moveGenerator(13);
moveGenerator(7);
moveGenerator(7);
moveGenerator(15);
yellowCorners();
}
}
/*
This method detemines that placement stage has finished
*/
public boolean yellowCornerFinished () {
for (int i = 0; i < cube[0].length; i++)
for (int j = 0; j < cube[0][i].length; j++) {
if (cube[0][i][j] != 6)
return false;
}
return true;
}
/*
This method rotates the cube for place yellow corners in
*/
public void rotateCubeForYellowCorners () {
if (cube[0][0][0] != 6 && cube[0][0][2] != 6 && cube[0][2][0] != 6 && cube[0][2][2] != 6) {
if (cube[1][0][2] == 6) {
}
else if (cube[4][0][2] == 6) {
moveGenerator(20);
}
else if (cube[3][0][2] == 6) {
moveGenerator(20);
moveGenerator(20);
}
else if (cube[2][0][2] == 6) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
}
else if (cube[0][0][0] != 6 && cube[0][0][2] != 6 && cube[0][2][0] == 6 && cube[0][2][2] != 6) {
}
else if (cube[0][0][0] != 6 && cube[0][0][2] != 6 && cube[0][2][0] != 6 && cube[0][2][2] == 6) {
moveGenerator(20);
}
else if (cube[0][0][0] != 6 && cube[0][0][2] == 6 && cube[0][2][0] != 6 && cube[0][2][2] != 6) {
moveGenerator(20);
moveGenerator(20);
}
else if (cube[0][0][0] == 6 && cube[0][0][2] != 6 && cube[0][2][0] != 6 && cube[0][2][2] != 6) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
else {
if (cube[4][0][0] == 6) {
}
else if (cube[3][0][0] == 6) {
moveGenerator(20);
}
else if (cube[2][0][0] == 6) {
moveGenerator(20);
moveGenerator(20);
}
else if (cube[1][0][0] == 6) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
}
}
/*
This method orients the corners of yellow side
*/
public void orientCorners () {
boolean orient = positionCubeForOrientCorners();
if (!orient) {
moveGenerator(15);
moveGenerator(1);
moveGenerator(15);
moveGenerator(5);
moveGenerator(13);
moveGenerator(3);
moveGenerator(15);
moveGenerator(5);
moveGenerator(14);
moveGenerator(9);
orientCorners();
}
}
/*
This methof psotions the cube in right position before orientCorners()
method eccecutes
*/
public boolean positionCubeForOrientCorners () {
boolean check = checkYellowCorners();
if (check)
return true;
int count1 = 0;
int count2 = 0;
int count3 = 0;
int count4 = 0;
count1 = countCorners();
moveGenerator(7);
count2 = countCorners();
moveGenerator(7);
count3 = countCorners();
moveGenerator(7);
count4 = countCorners();
moveGenerator(7);
if (count1 == 4) {
}
else if (count2 == 4) {
moveGenerator(7);
}
else if (count3 == 4) {
moveGenerator(8);
}
else if (count4 == 4) {
moveGenerator(9);
}
else if (count1 >= count2 && count1 >= count3 && count1 >= count4) {
rotateCubeForOrientCorners();
}
else if (count2 >= count1 && count2 >= count3 && count2 >= count4) {
moveGenerator(7);
rotateCubeForOrientCorners();
}
else if (count3 >= count1 && count3 >= count2 && count3 >= count4) {
moveGenerator(8);
rotateCubeForOrientCorners();
}
else if (count4 >= count1 && count4 >= count2 && count4 >= count3) {
moveGenerator(9);
rotateCubeForOrientCorners();
}
if (count1 == 4 || count2 == 4 || count3 == 4 || count4 == 4)
return true;
return false;
}
/*
This method chechs if yellow corner are oriented correctly
*/
public boolean checkYellowCorners () {
if (cube[1][0][0] == cube [1][1][1] && cube[2][0][2] == cube[2][1][1] &&
cube[2][0][0] == cube [2][1][1] && cube[3][0][2] == cube[3][1][1] &&
cube[4][0][0] == cube [4][1][1] && cube[1][0][2] == cube[1][1][1] &&
cube[3][0][0] == cube [3][1][1] && cube[4][0][2] == cube[4][1][1])
return true;
return false;
}
/*
This method counts the number of yellow corners in the right orientation
*/
public int countCorners () {
int count = 0;
if (cube[4][0][0] == cube [4][1][1] && cube[1][0][2] == cube[1][1][1])
count++;
if (cube[1][0][0] == cube [1][1][1] && cube[2][0][2] == cube[2][1][1])
count++;
if (cube[2][0][0] == cube [2][1][1] && cube[3][0][2] == cube[3][1][1])
count++;
if (cube[3][0][0] == cube [3][1][1] && cube[4][0][2] == cube[4][1][1])
count++;
return count;
}
/*
This methods rotates the cube before the corners are oriented
*/
public void rotateCubeForOrientCorners () {
if (cube[1][0][0] == cube [1][1][1] && cube[2][0][2] == cube[2][1][1] &&
cube[2][0][0] == cube [2][1][1] && cube[3][0][2] == cube[3][1][1]) {
}
else if (cube[4][0][0] == cube [4][1][1] && cube[1][0][2] == cube[1][1][1] &&
cube[1][0][0] == cube [1][1][1] && cube[2][0][2] == cube[2][1][1]) {
moveGenerator(20);
}
else if (cube[4][0][0] == cube [4][1][1] && cube[1][0][2] == cube[1][1][1] &&
cube[3][0][0] == cube [3][1][1] && cube[4][0][2] == cube[4][1][1]) {
moveGenerator(20);
moveGenerator(20);
}
else if (cube[2][0][0] == cube [2][1][1] && cube[3][0][2] == cube[3][1][1] &&
cube[3][0][0] == cube [3][1][1] && cube[4][0][2] == cube[4][1][1]) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
}
/*
This method orients the yellow cross
*/
public void orientCross () {
boolean check = checkYellowCross();
if (!check) {
boolean orient = positionCubeForOrientCross();
if (orient) {
yellowCrossClockwise();
orientCross();
}
else {
if (cube[4][0][1] == cube[1][1][1])
yellowCrossClockwise();
else
yellowCrossCounterClockwise();
}
}
}
/*
This method checks the the yellow cross is oriented correctly
*/
public boolean checkYellowCross () {
if (cube[4][0][1] == cube[4][1][1] && cube[1][0][1] == cube[1][1][1] &&
cube[2][0][1] == cube[2][1][1] && cube[3][0][1] == cube[3][1][1])
return true;
return false;
}
/*
This method places the cube in the correct position before the orient
cross algorithm can take place
*/
public boolean positionCubeForOrientCross () {
if (cube[4][0][1] != cube[4][1][1] && cube[1][0][1] != cube[1][1][1] &&
cube[2][0][1] != cube[2][1][1] && cube[3][0][1] != cube[3][1][1])
return true; // This indicates that all 4 sides pieces are incorect as oppose to 3
else if (cube[2][0][1] == cube[2][1][1]) { // If one side is correct need to make sure it is on
} // back side before algorithm can be applied
else if (cube[1][0][1] == cube[1][1][1]) {
moveGenerator(20);
}
else if (cube[4][0][1] == cube[4][1][1]) {
moveGenerator(20);
moveGenerator(20);
}
else if (cube[3][0][1] == cube[3][1][1]) {
moveGenerator(20);
moveGenerator(20);
moveGenerator(20);
}
return false;
}
/*
This method rotstes three yellow edge pieces in a clockwise direction
*/
public void yellowCrossClockwise () {
moveGenerator(2);
moveGenerator(7);
moveGenerator(16);
moveGenerator(15);
moveGenerator(2);
moveGenerator(18);
moveGenerator(13);
moveGenerator(7);
moveGenerator(2);
}
/*
This method rotstes three yellow edge pieces in an anticlockwise direction
*/
public void yellowCrossCounterClockwise (){
moveGenerator(2);
moveGenerator(9);
moveGenerator(16);
moveGenerator(15);
moveGenerator(2);
moveGenerator(18);
moveGenerator(13);
moveGenerator(9);
moveGenerator(2);
}
private class ButtonListener extends BeginnersMethod implements ActionListener {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < cube.length; i++)
for (int j = 0; j < cube[i].length; j++)
for (int k = 0; k < cube[i][j].length; k++) {
if (e.getSource() == cubeButtons[i][j][k]) {
if (white.isSelected()) {
cubeButtons[i][j][k].setBackground(Color.white);
}
else if (blue.isSelected()) {
cubeButtons[i][j][k].setBackground(Color.blue);
}
else if (red.isSelected()) {
cubeButtons[i][j][k].setBackground(Color.red);
}
else if (green.isSelected()) {
cubeButtons[i][j][k].setBackground(Color.green);
}
else if (orange.isSelected()) {
cubeButtons[i][j][k].setBackground(Color.orange);
}
else if (yellow.isSelected()){
cubeButtons[i][j][k].setBackground(Color.yellow);
}
}
}
if (e.getSource() == random) {
this.randomShuffle();
for (int i = 0; i < cube.length; i++)
for (int j = 0; j < cube[i].length; j++)
for (int k = 0; k < cube[i][j].length; k++) {
int value = this.getPosition(i, j, k);
cubeButtons[i][j][k].setBackground(numToColor(value));
}
}
else if (e.getSource() == answer) {
display.setText(null);
this.solution.clear();
this.moves.clear();
this.rotations.clear();
colorToNum();
this.solve();
if (this.checkCube())
display.setText("Solution: "+this.returnSolution()+
"\n\nThe number of moves is "+moves.size()+
"\n\nThe number of rotations is "+rotations.size());
else
display.setText("Please check cube: a colour is on more than 9 places");
}
}
public Color numToColor (int i) {
switch (i) {
case 1:
return Color.white;
case 2:
return Color.blue;
case 3:
return Color.red;
case 4:
return Color.green;
case 5:
return Color.orange;
case 6:
return Color.yellow;
default:
return Color.gray;
}
}
public void colorToNum () {
for (int i = 0; i < cube.length; i++)
for (int j = 0; j < cube[i].length; j++)
for (int k = 0; k < cube[i][j].length; k++) {
if (cubeButtons[i][j][k].getBackground() == Color.white)
this.setPosition(1,i,j,k);
else if (cubeButtons[i][j][k].getBackground() == Color.blue)
this.setPosition(2,i,j,k);
else if (cubeButtons[i][j][k].getBackground() == Color.red)
this.setPosition(3,i,j,k);
else if (cubeButtons[i][j][k].getBackground() == Color.green)
this.setPosition(4,i,j,k);
else if (cubeButtons[i][j][k].getBackground() == Color.orange)
this.setPosition(5,i,j,k);
else if (cubeButtons[i][j][k].getBackground() == Color.yellow)
this.setPosition(6,i,j,k);
else
this.setPosition(0,i,j,k);
}
}
}
public static void main (String [] args) {
BeginnersMethod test = new BeginnersMethod ();
test.buildInterface();
}
}
| [
"[email protected]"
] | |
0365e35ee02f6f1cead938ed00bc7cd8dd7ae21e | e8b31153fa5c323affa9d1a8feddc8e4abbf8b1e | /src/main/java/org/sunflow/core/shader/UberShader.java | fac32b5b39f9cc1d5709a83823b488e7ac93ed66 | [] | no_license | rpax/sunflow | b1c17e0fdbb69c42e3c438490da9c27f2b4d06b5 | 68fececac4a916056959a8336138d1e28c91af8d | refs/heads/master | 2020-06-11T06:56:55.543790 | 2016-12-06T15:22:15 | 2016-12-06T15:22:15 | 75,740,281 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,529 | java | package org.sunflow.core.shader;
import org.sunflow.SunflowAPI;
import org.sunflow.core.ParameterList;
import org.sunflow.core.Ray;
import org.sunflow.core.Shader;
import org.sunflow.core.ShadingState;
import org.sunflow.core.Texture;
import org.sunflow.image.Color;
import org.sunflow.math.MathUtils;
import org.sunflow.math.OrthoNormalBasis;
import org.sunflow.math.Vector3;
public class UberShader implements Shader {
private Color diff;
private Color spec;
private Texture diffmap;
private Texture specmap;
private float diffBlend;
private float specBlend;
private float glossyness;
private int numSamples;
public UberShader() {
diff = spec = Color.GRAY;
diffmap = specmap = null;
diffBlend = specBlend = 1;
glossyness = 0;
numSamples = 4;
}
public boolean update(ParameterList pl, SunflowAPI api) {
diff = pl.getColor("diffuse", diff);
spec = pl.getColor("specular", spec);
String filename;
filename = pl.getString("diffuse.texture", null);
if (filename != null)
// EP : Made texture cache local to a SunFlow API instance
diffmap = api.getTextureCache().getTexture(api.resolveTextureFilename(filename), false);
filename = pl.getString("specular.texture", null);
if (filename != null)
// EP : Made texture cache local to a SunFlow API instance
specmap = api.getTextureCache().getTexture(api.resolveTextureFilename(filename), false);
diffBlend = MathUtils.clamp(pl.getFloat("diffuse.blend", diffBlend), 0, 1);
specBlend = MathUtils.clamp(pl.getFloat("specular.blend", diffBlend), 0, 1);
glossyness = MathUtils.clamp(pl.getFloat("glossyness", glossyness), 0, 1);
numSamples = pl.getInt("samples", numSamples);
return true;
}
public Color getDiffuse(ShadingState state) {
return diffmap == null ? diff : Color.blend(diff, diffmap.getPixel(state.getUV().x, state.getUV().y), diffBlend);
}
public Color getSpecular(ShadingState state) {
return specmap == null ? spec : Color.blend(spec, specmap.getPixel(state.getUV().x, state.getUV().y), specBlend);
}
public Color getRadiance(ShadingState state) {
// make sure we are on the right side of the material
state.faceforward();
// direct lighting
state.initLightSamples();
state.initCausticSamples();
// EP : Added transparency management
float alpha;
if (!isOpaque() && diffmap != null && (alpha = diffmap.getOpacityAlpha(state.getUV().x, state.getUV().y)) <= 0.99999) {
// Ignore glossiness for half transparent pixels
Color c = state.diffuse(getDiffuse(state));
Vector3 refrDir = state.getRay().getDirection();
Color refraction = state.traceRefraction(new Ray(state.getPoint(), refrDir), 0);
return c.mul(alpha).madd(1 - alpha, refraction);
} else {
// EP : End of modification
Color d = getDiffuse(state);
Color lr = state.diffuse(d);
if (!state.includeSpecular())
return lr;
if (glossyness == 0) {
float cos = state.getCosND();
float dn = 2 * cos;
Vector3 refDir = new Vector3();
refDir.x = (dn * state.getNormal().x) + state.getRay().getDirection().x;
refDir.y = (dn * state.getNormal().y) + state.getRay().getDirection().y;
refDir.z = (dn * state.getNormal().z) + state.getRay().getDirection().z;
Ray refRay = new Ray(state.getPoint(), refDir);
// compute Fresnel term
cos = 1 - cos;
float cos2 = cos * cos;
float cos5 = cos2 * cos2 * cos;
Color spec = getSpecular(state);
Color ret = Color.white();
ret.sub(spec);
ret.mul(cos5);
ret.add(spec);
return lr.add(ret.mul(state.traceReflection(refRay, 0)));
} else
return lr.add(state.specularPhong(getSpecular(state), 2 / glossyness, numSamples));
// EP : Added transparency management
}
// EP : End of modification
}
public void scatterPhoton(ShadingState state, Color power) {
Color diffuse, specular;
// make sure we are on the right side of the material
state.faceforward();
diffuse = getDiffuse(state);
specular = getSpecular(state);
state.storePhoton(state.getRay().getDirection(), power, diffuse);
float d = diffuse.getAverage();
float r = specular.getAverage();
double rnd = state.getRandom(0, 0, 1);
if (rnd < d) {
// photon is scattered
power.mul(diffuse).mul(1.0f / d);
OrthoNormalBasis onb = state.getBasis();
double u = 2 * Math.PI * rnd / d;
double v = state.getRandom(0, 1, 1);
float s = (float) Math.sqrt(v);
float s1 = (float) Math.sqrt(1.0 - v);
Vector3 w = new Vector3((float) Math.cos(u) * s, (float) Math.sin(u) * s, s1);
w = onb.transform(w, new Vector3());
state.traceDiffusePhoton(new Ray(state.getPoint(), w), power);
} else if (rnd < d + r) {
if (glossyness == 0) {
float cos = -Vector3.dot(state.getNormal(), state.getRay().getDirection());
power.mul(diffuse).mul(1.0f / d);
// photon is reflected
float dn = 2 * cos;
Vector3 dir = new Vector3();
dir.x = (dn * state.getNormal().x) + state.getRay().getDirection().x;
dir.y = (dn * state.getNormal().y) + state.getRay().getDirection().y;
dir.z = (dn * state.getNormal().z) + state.getRay().getDirection().z;
state.traceReflectionPhoton(new Ray(state.getPoint(), dir), power);
} else {
float dn = 2.0f * state.getCosND();
// reflected direction
Vector3 refDir = new Vector3();
refDir.x = (dn * state.getNormal().x) + state.getRay().dx;
refDir.y = (dn * state.getNormal().y) + state.getRay().dy;
refDir.z = (dn * state.getNormal().z) + state.getRay().dz;
power.mul(spec).mul(1.0f / r);
OrthoNormalBasis onb = state.getBasis();
double u = 2 * Math.PI * (rnd - r) / r;
double v = state.getRandom(0, 1, 1);
float s = (float) Math.pow(v, 1 / ((1.0f / glossyness) + 1));
float s1 = (float) Math.sqrt(1 - s * s);
Vector3 w = new Vector3((float) Math.cos(u) * s1, (float) Math.sin(u) * s1, s);
w = onb.transform(w, new Vector3());
state.traceReflectionPhoton(new Ray(state.getPoint(), w), power);
}
}
}
// EP : Added transparency management
public boolean isOpaque() {
return diffmap == null || !(diffmap.isTransparent());
}
public Color getOpacity(ShadingState state) {
return diffmap != null ? diffmap.getOpacity(state.getUV().x, state.getUV().y) : Color.WHITE;
}
// EP : End of modification
} | [
"[email protected]"
] | |
5e476f37dea4ffcb99f5af46b8f2d4075105b7dd | c6e420fb77953fd1bad4fadba6970fc606bc5344 | /app/src/main/java/org/dhamma/dhammaplayer/ui/main/PageViewModel.java | 33e8e48b40878c469da18d537a6e0151a00fe001 | [] | no_license | akhurange/dhamma-player | 795440d761c1f616cd60b9ef2daf295139d19b1c | b4bacd51cb3e647644fcaf228f21c09827c7f9d8 | refs/heads/master | 2020-12-27T17:42:15.546621 | 2020-03-14T10:40:52 | 2020-03-14T10:40:52 | 237,992,986 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 746 | java | package org.dhamma.dhammaplayer.ui.main;
import androidx.arch.core.util.Function;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Transformations;
import androidx.lifecycle.ViewModel;
public class PageViewModel extends ViewModel {
private MutableLiveData<Integer> mIndex = new MutableLiveData<>();
private LiveData<String> mText = Transformations.map(mIndex, new Function<Integer, String>() {
@Override
public String apply(Integer input) {
return "Hello world from section: " + input;
}
});
public void setIndex(int index) {
mIndex.setValue(index);
}
public LiveData<String> getText() {
return mText;
}
} | [
"[email protected]"
] | |
590779b5ac0db8972dcd580e9d8ccbe253ec455c | 4a35eb46507eb8207f634e6dad23762d0aec94df | /project/MapExplore/jMetal-jmetal-5.1/jmetal-problem/src/main/java/org/uma/jmetal/problem/multiobjective/zdt/ZDT3.java | 9215945fc27a5ab9f29f1f2c564bbb063624980a | [] | no_license | fairanswers/fss16joe | 8800ad81c60ab06f90b9643bf601c6c2c9a51107 | f5dde87038ec5404a6bb2d9a538b2ceef571ac9d | refs/heads/master | 2020-05-22T06:44:32.138162 | 2016-12-07T19:46:54 | 2016-12-07T19:46:54 | 65,820,114 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,237 | java | // ZDT3.java
//
// Author:
// Antonio J. Nebro <[email protected]>
// Juan J. Durillo <[email protected]>
//
// Copyright (c) 2011 Antonio J. Nebro, Juan J. Durillo
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package org.uma.jmetal.problem.multiobjective.zdt;
import org.uma.jmetal.problem.impl.AbstractDoubleProblem;
import org.uma.jmetal.solution.DoubleSolution;
import java.util.ArrayList;
import java.util.List;
/**
* Class representing problem ZDT3
*/
@SuppressWarnings("serial")
public class ZDT3 extends AbstractDoubleProblem {
/** Constructor. Creates default instance of problem ZDT3 (30 decision variables) */
public ZDT3() {
this(30);
}
/**
* Constructor.
* Creates a instance of ZDT3 problem.
*
* @param numberOfVariables Number of variables.
*/
public ZDT3(Integer numberOfVariables) {
setNumberOfVariables(numberOfVariables);
setNumberOfObjectives(2);
setName("ZDT3");
List<Double> lowerLimit = new ArrayList<>(getNumberOfVariables()) ;
List<Double> upperLimit = new ArrayList<>(getNumberOfVariables()) ;
for (int i = 0; i < getNumberOfVariables(); i++) {
lowerLimit.add(0.0);
upperLimit.add(1.0);
}
setLowerLimit(lowerLimit);
setUpperLimit(upperLimit);
}
/** Evaluate() method */
public void evaluate(DoubleSolution solution) {
int numberOfVariables = getNumberOfVariables() ;
double[] f = new double[getNumberOfObjectives()];
double[] x = new double[numberOfVariables] ;
f[0] = solution.getVariableValue(0);
double g = this.evalG(solution);
double h = this.evalH(f[0], g);
f[1] = h * g;
solution.setObjective(0, f[0]);
solution.setObjective(1, f[1]);
}
/**
* Returns the value of the ZDT2 function G.
*
* @param solution Solution
* @throws org.uma.jmetal45.util.JMetalException
*/
private double evalG(DoubleSolution solution) {
double g = 0.0;
for (int i = 1; i < solution.getNumberOfVariables(); i++) {
g += solution.getVariableValue(i);
}
double constant = 9.0 / (solution.getNumberOfVariables() - 1);
g = constant * g;
g = g + 1.0;
return g;
}
/**
* Returns the value of the ZDT3 function H.
*
* @param f First argument of the function H.
* @param g Second argument of the function H.
*/
public double evalH(double f, double g) {
double h ;
h = 1.0 - Math.sqrt(f / g)
- (f / g) * Math.sin(10.0 * Math.PI * f);
return h;
}
}
| [
"[email protected]"
] | |
b3e17d11fd4352cdd50affc9fd6f0237f00a3716 | 6ac195a3d659b9055ea09c1fe008dede86e35b6f | /src/main/java/com/zhaoguhong/baymax/security/config/CasSecurityConfig.java | 90a45e3b11fe35dc1ce4093695a5bdf57cb13f62 | [
"Apache-2.0"
] | permissive | liuhangz1/baymax | fb7bcc61cf8f56c5de7518eb6dcd50a5fd6032aa | 75d7e878187ce7da1e1687344c01dda5b9972c53 | refs/heads/master | 2022-11-29T21:47:18.744924 | 2020-08-17T03:30:11 | 2020-08-17T03:30:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,799 | java | package com.zhaoguhong.baymax.security.config;
import org.jasig.cas.client.session.SingleSignOutFilter;
import org.jasig.cas.client.validation.Cas20ServiceTicketValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.security.cas.ServiceProperties;
import org.springframework.security.cas.authentication.CasAssertionAuthenticationToken;
import org.springframework.security.cas.authentication.CasAuthenticationProvider;
import org.springframework.security.cas.web.CasAuthenticationEntryPoint;
import org.springframework.security.cas.web.CasAuthenticationFilter;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.core.userdetails.AuthenticationUserDetailsService;
import org.springframework.security.web.authentication.www.BasicAuthenticationFilter;
import org.springframework.stereotype.Component;
/**
* @author guhong
* @date 2019/5/17
*/
@Component
public class CasSecurityConfig extends WebSecurityConfig {
@Autowired
private CasProperties casProperties;
@Autowired
private AuthenticationUserDetailsService<CasAssertionAuthenticationToken> casAuthenticationUserDetailsService;
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
if (casProperties.isEnable()) {
http.authorizeRequests()
// 添加 cas 认证 fifter
.and().addFilterBefore(casAuthenticationFilter(), BasicAuthenticationFilter.class)
// 添加 cas 登出 fifter
.addFilterBefore(singleSignOutFilter(), CasAuthenticationFilter.class)
.exceptionHandling()
// cas认证入口
.authenticationEntryPoint(casAuthenticationEntryPoint());
}
}
/**
* 配置单点项目信息
*/
@Bean
public ServiceProperties serviceProperties() {
ServiceProperties sp = new ServiceProperties();
// 单点登录成功回调地址
sp.setService(casProperties.getClientCasUrl());
return sp;
}
/**
* cas认证入口
*/
@Bean
public CasAuthenticationEntryPoint casAuthenticationEntryPoint() {
CasAuthenticationEntryPoint casAuthenticationEntryPoint = new CasAuthenticationEntryPoint();
casAuthenticationEntryPoint.setLoginUrl(casProperties.getLoginUrl());
casAuthenticationEntryPoint.setServiceProperties(serviceProperties());
return casAuthenticationEntryPoint;
}
/**
* cas校验器
*/
@Bean
public Cas20ServiceTicketValidator ticketValidator() {
return new Cas20ServiceTicketValidator(casProperties.getServerUrl());
}
/**
* cas认证Provider
*/
@Bean
public CasAuthenticationProvider casAuthenticationProvider() {
CasAuthenticationProvider provider = new CasAuthenticationProvider();
provider.setServiceProperties(serviceProperties());
provider.setTicketValidator(ticketValidator());
// 设置UserDetailsService
provider.setAuthenticationUserDetailsService(casAuthenticationUserDetailsService);
provider.setKey("CAS_PROVIDER_LOCALHOST_8123");
return provider;
}
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
// 设置cas认证provider
auth.authenticationProvider(casAuthenticationProvider());
}
/**
* 单点登出过滤器
*/
@Bean
public SingleSignOutFilter singleSignOutFilter() {
SingleSignOutFilter singleSignOutFilter = new SingleSignOutFilter();
singleSignOutFilter.setCasServerUrlPrefix(casProperties.getServerUrl());
singleSignOutFilter.setIgnoreInitConfiguration(true);
return singleSignOutFilter;
}
/**
* 设置认证 Provider 为 cas 认证
*/
@Override
protected void configure(AuthenticationManagerBuilder auth)
throws Exception {
super.configure(auth);
if (casProperties.isEnable()) {
auth.authenticationProvider(casAuthenticationProvider());
}
}
/**
* cas认证过滤器
*/
@Bean
public CasAuthenticationFilter casAuthenticationFilter()
throws Exception {
CasAuthenticationFilter filter = new CasAuthenticationFilter();
filter.setServiceProperties(serviceProperties());
// 设置认证manager
filter.setAuthenticationManager(authenticationManager());
// 可以手动设置认证成功处理器,和认证失败处理器
// filter.setAuthenticationFailureHandler(authenticationFailureHandler);
// filter.setAuthenticationSuccessHandler(simpleUrlAuthenticationSuccessHandler());
// 设置客户端cas登录url,默认值是 /login/cas
//filter.setFilterProcessesUrl("/login/cas")
return filter;
}
}
| [
"[email protected]"
] | |
650321d4cccdc948276a44ef18aa23cac888c63c | 9509a3a2303af939ea459eac91ac8d62ea6264cf | /learn-service-impl/learn-servicve-author-regist/src/main/java/com/mayikt/impl/author/service/AuthApplication.java | 95101e91b0a65ef411b65a9ff4e6eb4c584de3a9 | [] | no_license | dream-png/learn-shopping | 8b4802eb92eb213e6c3c6d154a12359e881d5c6f | 4e55a6ab41f76d468d394e51cfd34d0c473f43b8 | refs/heads/master | 2023-07-25T23:14:39.971943 | 2019-10-13T16:24:25 | 2019-10-13T16:24:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,119 | java | package com.mayikt.impl.author.service;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
* 认证启动
*
*
* @description:
* @author: 97后互联网架构师-余胜军
* @contact: QQ644064779、微信yushengjun644 www.mayikt.com
* @date: 2019年1月3日 下午3:03:17
* @version V1.0
* @Copyright 该项目“基于SpringCloud2.x构建微服务电商项目”由每特教育|蚂蚁课堂版权所有,未经过允许的情况下,
* 私自分享视频和源码属于违法行为。
*/
@SpringBootApplication
@EnableEurekaClient
// @EnableApolloConfig
@EnableFeignClients(basePackages = "com.mayikt") //开启FeignClient支持
@MapperScan(basePackages = "com.mayikt.impl.author.service.auth.mapper")
public class AuthApplication {
public static void main(String[] args) {
SpringApplication.run(AuthApplication.class, args);
}
}
| [
"[email protected]"
] | |
1ad30b81c5c857239ce7dd05b145e40e230db884 | 1c3d8588c43d61e611dacd0752e31b792290999b | /Java_develpMonster_PT/src/this_is_java/chap07/Parent3.java | ad1c6baf6b59a2bfdd95683edd6237d65de34e8b | [] | no_license | kimjjing1004/Java_DevelopMonster_PT | 78b8b4fd90752dc91d24a76fd3f66883611ee3cb | 8925c712d7631af75b9504e3b1661a0ebcf112a1 | refs/heads/master | 2023-07-02T07:44:49.492136 | 2021-08-02T15:22:35 | 2021-08-02T15:22:35 | 370,984,436 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 61 | java | package this_is_java.chap07;
public class Parent3 {
}
| [
"[email protected]"
] | |
72c806c66f94a715b6ddd2dbaceef7d36667d609 | 87b5888f3d27212c01ba0259c4e98c61b52e99ed | /kalah-game/src/main/java/com/backbase/kalah/configs/GlobalExceptionHandler.java | cc2dd810f4939fa0a6c65c3ac13671275a8dd412 | [] | no_license | sachithdickwella/kalah-repo | c66a306c649ae36d82368a1ba2d743038c5111e1 | 9d4643626eb2a0193b21577302e5b97cc7412d2c | refs/heads/master | 2020-12-06T13:00:33.812950 | 2020-01-21T05:24:06 | 2020-01-21T05:24:06 | 232,469,544 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,189 | java | package com.backbase.kalah.configs;
import com.backbase.kalah.records.HttpErrorResponse;
import com.backbase.kalah.util.InvalidPitUserException;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import javax.servlet.http.HttpServletRequest;
/**
* Application level exception handler. Handle every kind of exception declared under this class and
* transform them to custom http response to understand by any client including http clients.
*
* Declaration of {@link ControllerAdvice} annotation make this class to be stored in Spring beans in
* {@link org.springframework.context.ApplicationContext}.
*
* @author Sachith Dickwella
*/
@ControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
/**
* Handle {@link InvalidPitUserException} exceptions coming from downstream services and orchestrate
* custom {@link HttpErrorResponse} wrapped with {@link ResponseEntity}.
*
* @param request instance of {@link HttpServletRequest} pass by upstream function.
* @param ex instance that's been thrown by the services.
* @return instance of {@link HttpErrorResponse} wrapped by {@link ResponseEntity}.
*/
@ExceptionHandler(InvalidPitUserException.class)
public ResponseEntity<HttpErrorResponse> handleInvalidPitUser(@NotNull HttpServletRequest request,
@NotNull InvalidPitUserException ex) {
final var status = HttpStatus.NOT_ACCEPTABLE;
return ResponseEntity.status(status)
.body(HttpErrorResponse.builder()
.timestamp()
.status(status.value())
.error(status.getReasonPhrase())
.message(ex.getMessage())
.payload(ex.getPayload())
.build());
}
}
| [
"[email protected]"
] | |
4ed0c2842301708ec4d37afcc665d3a4d202134b | 6ba21069b587e3bfe8e794d046e1fe2f85aebb65 | /safecoldj/src/main/java/com/bankledger/safecoldj/core/HDAddress.java | ff1cac4aabe9db13655395a51da2dfe6d3b4c957 | [] | no_license | ulwfcyvi791837060/safegem-cold-wallet | 704c783debc9c0b48fe716e437f71cbdd3f89f08 | 86d7729b4de0a29a077b918d528cae61be0dc088 | refs/heads/master | 2022-02-27T15:55:03.324818 | 2019-09-17T02:09:24 | 2019-09-17T02:09:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,426 | java | package com.bankledger.safecoldj.core;
import com.bankledger.safecoldj.Currency;
import com.bankledger.safecoldj.SafeColdSettings;
import com.bankledger.safecoldj.utils.Utils;
import java.io.Serializable;
public class HDAddress implements Comparable<HDAddress>, Serializable {
public enum AvailableState {
STATE_AVAILABLE(0),
STATE_DISABLED(1);
private int value;
AvailableState(int value) {
this.value = value;
}
public int getValue() {
return this.value;
}
}
private String coin;
private String address;
private String alias;
private int addressIndex;
private AbstractHD.PathType pathType;
private byte[] pubKey;
private AvailableState availableState;
public HDAddress() {
}
public HDAddress(byte[] pubKey, AbstractHD.PathType pathType, int addressIndex, Currency mCurrency) {
this(Utils.toAddress(Utils.sha256hash160(pubKey), mCurrency), pubKey, pathType, addressIndex, mCurrency.coin, "");
}
public HDAddress(String address, byte[] pubKey, AbstractHD.PathType pathType, int
addressIndex, String coin, String alias) {
this(address, pubKey, pathType, addressIndex, coin, alias, AvailableState.STATE_AVAILABLE);
}
public HDAddress(String address, byte[] pubKey, AbstractHD.PathType pathType, int
addressIndex, String coin, String alias, AvailableState availableState) {
this.address = address;
this.addressIndex = addressIndex;
this.pathType = pathType;
this.pubKey = pubKey;
this.alias = alias;
this.coin = coin;
this.availableState = availableState;
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public int getAddressIndex() {
return addressIndex;
}
public void setAddressIndex(int addressIndex) {
this.addressIndex = addressIndex;
}
public AbstractHD.PathType getPathType() {
return pathType;
}
public void setPathType(AbstractHD.PathType pathType) {
this.pathType = pathType;
}
public byte[] getPubKey() {
return pubKey;
}
public void setPubKey(byte[] pubKey) {
this.pubKey = pubKey;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getCoin() {
return coin;
}
public void setCoin(String coin) {
this.coin = coin;
}
public AvailableState getAvailableState() {
return availableState;
}
public void setAvailableState(AvailableState availableState) {
this.availableState = availableState;
}
public boolean isUsdt() {
return SafeColdSettings.USDT.equalsIgnoreCase(coin);
}
@Override
public int compareTo(HDAddress address) {
return coin.compareTo(address.coin);
}
@Override
public String toString() {
return "HDAddress{" +
"coin='" + coin + '\'' +
", address='" + address + '\'' +
", alias='" + alias + '\'' +
", addressIndex=" + addressIndex +
", pathType=" + pathType +
", availableState=" + availableState +
'}';
}
} | [
"[email protected]"
] | |
ea76dd9cbd19985dc016eff75517339a6720e606 | dea4db440d23ce55d646cd4ca3e979a3014300e4 | /src/main/java/com/example/demo/service/DemoService.java | b103147b2556192e9fa777cf924567d59633a260 | [] | no_license | gxllyym/SpringBoot-Mybatis | 756ec1cb73fbfefe76025808ae7be4824f2ae11b | 3a303a9d81d958744edd6e5b254fdbb4d860cdbf | refs/heads/master | 2020-08-24T01:01:50.632711 | 2019-10-22T06:28:11 | 2019-10-22T06:28:11 | 216,737,090 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 169 | java | package com.example.demo.service;
import java.util.List;
import com.example.demo.model.DemoModel;
public interface DemoService {
public List<DemoModel> getall();
}
| [
"[email protected]"
] | |
e60bab0dbf5aa8b210dfd3410a236c2ece724753 | 4cba3d6c56213a9d2af5c317c4ad7d9fc4801d6f | /src/Model/Application.java | 020d1b9305de1c5e8f48fc3129cc112e747fdc61 | [] | no_license | DieJie/FinalProject | fcf9c66c0afe2660e3c9cbdb48908a9ecab15bec | 40a0bdfd8485b11789e0911b7b577530a44aeec6 | refs/heads/master | 2022-05-26T21:48:54.203905 | 2020-05-01T08:12:58 | 2020-05-01T08:12:58 | 260,213,216 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,791 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Model;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author DivaPrasetya
*/
public class Application{
private ArrayList<Person> daftarUser;
private ArrayList<KelasTugasAkhir> daftarKTA;
public Application(){
daftarUser = new ArrayList();
daftarKTA = new ArrayList();
}
public void addMahasiswa(String username,String password,String nama,String nohp,String ttl){
Mahasiswa m = new Mahasiswa(username,password,nama,nohp,ttl);
daftarUser.add(m);
}
public Mahasiswa getMahasiswa(int nim){
for(Person p : daftarUser){
if(p instanceof Mahasiswa){
if(((Mahasiswa) p).getNim() == nim){
return (Mahasiswa)p;
}
}
}
return null;
}
public void deleteMahasiswa(int nim){
try{
daftarUser.remove(getMahasiswa(nim));
}catch(NullPointerException npe){
throw npe;
}
}
public void addDosen(String username,String password,String nama,String nohp,String ttl){
Dosen d = new Dosen(username,password,nama,nohp,ttl);
daftarUser.add(d);
}
public Dosen getDosen(int nidn){
for(Person p : daftarUser){
if(p instanceof Dosen){
if(((Dosen) p).getNidn() == nidn){
return (Dosen)p;
}
}
}
return null;
}
public void deleteDosen(int nidn){
try{
daftarUser.remove(getDosen(nidn));
}catch(NullPointerException npe){
throw npe;
}
}
public String[] getListKodeKelas(){
String[] listKodeKelas=new String[daftarKTA.size()];
int i = 0;
for (KelasTugasAkhir b: daftarKTA){
listKodeKelas[i] = b.KodeKelas;
i++;
}
return listKodeKelas;
}
public void createKelasTA(String topik, Dosen d){
d.createKelompokTA(topik, d);
daftarKTA.add(d.getKelasTA());
d.getKelasTA().addDosen(d);
}
public List<Person> getDaftarUser() {
return daftarUser;
}
public List<KelasTugasAkhir> getDaftarKTA() {
return daftarKTA;
}
public ArrayList<Dosen> SearchListDosen(String KodeKelas){
for (KelasTugasAkhir KTA: daftarKTA){
if (KTA.getKodeKelas() == KodeKelas){
return (ArrayList<Dosen>) (KTA.getTimDosen());
}
}
return null;
}
public KelasTugasAkhir SearchKTA(String KodeKelas){
for (KelasTugasAkhir KTA: daftarKTA){
if (KTA.getKodeKelas() == KodeKelas){
return KTA;
}
}
return null;
}
public ArrayList<Mahasiswa> SearchListMahasiswa(String KodeKelas){
for (KelasTugasAkhir KTA: daftarKTA){
if (KTA.getKodeKelas().equals(KodeKelas)){
return (ArrayList<Mahasiswa>) (KTA.getDaftarMhsTA());
}
}
return null;
}
public Person searchUser(String username, String password){
for(Person User: daftarUser){
if(User.getUsername().equals(username) && User.getPassword().equals(password)){
return User;
}
}
return null;
}
public Person searchUser(String nama){
for(Person User: daftarUser){
if(User.getNama().equals(nama)){
return User;
}
}
return null;
}
public int searchUserNum(String nama){
int i = 0;
for(Person User: daftarUser){
if(User.getNama().equals(nama)){
return i;
}
i++;
}
return -1;
}
public void updateMahasiswa(String username,String password,String nama,String nohp,String ttl,int i){
Mahasiswa m = new Mahasiswa(username,password,nama,nohp,ttl);
daftarUser.set(i, m);
}
public void updateDosen(String username,String password,String nama,String nohp,String ttl,int i){
Dosen d = new Dosen(username,password,nama,nohp,ttl);
daftarUser.set(i, d);
}
public void deleteKTA(String KodeKelas, Dosen d){
d.delKTA();
KelasTugasAkhir KTA = SearchKTA(KodeKelas);
int i = -1;
for(KelasTugasAkhir kta: daftarKTA){
i++;
if(kta.KodeKelas == KTA.KodeKelas){
break;
}
}
daftarKTA.remove(i);
}
}
| [
"[email protected]"
] | |
8446ece3cbb1047e8615bb3cf0fc82360704c0ad | 271b0c6cdc1e0a4afd47e50010218b9ecd34bb9e | /Shopping/src/main/java/com/web/controller/back/VoiceController.java | bde386a080073c4a05820f518f517adca40b3b57 | [] | no_license | yujiantong/Shopping | 2be7b9aac7b57a5fe591c824dce3e796eca10dbd | c547046a332281bab93a44136f29778bbd7da8ec | refs/heads/master | 2022-12-26T01:27:50.785492 | 2020-07-13T01:58:55 | 2020-07-13T01:58:55 | 204,835,599 | 0 | 0 | null | 2022-12-16T07:26:02 | 2019-08-28T02:57:31 | Java | UTF-8 | Java | false | false | 490 | java | package com.web.controller.back;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("VoiceController")
public class VoiceController {
@RequestMapping("voice")
public String voice(String strVoice) {
//strVoice = "你好,很高兴见到你";
System.out.println("Speak:"+strVoice+"***==start");
//VoiceUtil.speak(strVoice);
System.out.println("over---");
return "manager/voice";
}
}
| [
"[email protected]"
] | |
061d0f1f4f78d8a0b240c5b16c248d24d1b7c2eb | ab15767e55c7e01ecc665163edadc6de579f494c | /src/CommonUseClass/DateDemo.java | 25c9c9535410ce4d842a3085ec421173ddc603a3 | [] | no_license | Esioner/JavaTestDemo | 2409577956c67221fb6906a315460d3ee230ac86 | 91c5fce0907eae4faffe990d39fa50ed4b76825c | refs/heads/master | 2021-08-31T17:36:43.575099 | 2017-12-22T08:12:47 | 2017-12-22T08:12:47 | 110,812,144 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 857 | java | package CommonUseClass;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class DateDemo {
public static void main(String args[]) {
// Date date= new Date();
// System.out.println(date);
// Calendar calendar = Calendar.getInstance();
// System.out.println(calendar.get(Calendar.MILLISECOND));
// String formt = "yyyy-MM-dd- HH:mm:ss:SSS";
// SimpleDateFormat dateFormat = new SimpleDateFormat(formt);
// System.out.println(dateFormat.format(new Date()));
String strDate = "2017-11-30 14:26:32:666";
String pat = "yyyy-MM-DD HH:mm:ss:SSS";
SimpleDateFormat sdf = new SimpleDateFormat(pat);
try {
Date date = sdf.parse(strDate);
System.out.println(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
44daf1bfb2a49e668f2e83a4bea530e560321bc4 | 5cb9c6dd41f96ab0c138322636196f3f4f4d5630 | /Daily_Code_Record/02-18-18/src/Solution.java | 8d5e3d73815c4e176b78c21e2290b4ea733f3bc5 | [] | no_license | yoyoy74662000/Java_Practice | 214cbf211d1812ec9b62c9b3e69b34b3e9f0391e | d18bc8f35fa55cf9493a375113f8c6122c3acf1b | refs/heads/master | 2020-03-22T23:03:51.953556 | 2018-07-11T19:46:47 | 2018-07-11T19:46:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,464 | java | import java.util.*;
public class Solution {
public static void main(String[] args) {
int[][] edges = {{0,1},{0,2},{0,3},{1,4}};
int n = 5;
System.out.println(validTree(n, edges));
}
private static boolean validTree(int n, int[][] edges) {
if(n == 0) return false;
if(edges.length != n - 1) return false;
Map<Integer, Set<Integer>> graph = initializeGraph(n, edges);
Deque<Integer> queue = new ArrayDeque<>();
HashSet<Integer> hashSet = new HashSet<>();
int startNum = 0;
queue.offerLast(startNum);
hashSet.add(startNum);
while (!queue.isEmpty()) {
int node = queue.pollFirst();
for(Integer neighbor: graph.get(node)) {
if(hashSet.contains(neighbor)){
continue;
}
queue.offerLast(neighbor);
hashSet.add(neighbor);
}
}
return (hashSet.size() == n);
}
private static Map<Integer, Set<Integer>> initializeGraph(int n, int[][] edges) {
Map<Integer, Set<Integer>> graph = new HashMap<>();
for(int i = 0; i < n ; i++) {
graph.put(i, new HashSet<>());
}
for(int i = 0; i < edges.length; i++) {
int u = edges[i][0];
int v = edges[i][1];
graph.get(u).add(v);
graph.get(v).add(u);
}
return graph;
}
}
| [
"[email protected]"
] | |
f3d7b7cbbb89d9867ef3c164df5b467fe6321469 | 7663d390b7a0b4988e6339a5d62129b1582708d9 | /authentication/src/main/java/com/kidventure/controller/ApiController.java | 6e00fbf6239a9be5c5e9038120430edd35ee3b56 | [] | no_license | akankshamathur/springboot_microservice_skeleton | ddaf2f836ad4ee756e499b53c64df62faf6754fc | 7f13ab1b448efeab2fd9beb23a813636c6d8aff9 | refs/heads/master | 2021-07-19T16:15:47.112772 | 2020-05-28T08:55:01 | 2020-05-28T08:55:01 | 175,605,493 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,603 | java | package com.kidventure.controller;
import com.kidventure.command.LoginCommand;
import com.kidventure.command.TokenCommand;
import com.kidventure.config.security.service.TokenService;
import com.kidventure.model.ConsumerProfile;
import com.kidventure.model.User;
import com.kidventure.repository.UserRepository;
import com.kidventure.services.impl.ConsumerProfileImpl;
import com.kidventure.utility.ApiSuccessCode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping(value = "/auth")
public class ApiController {
private final TokenService tokenService;
private final UserRepository userRepository;
private static final Logger logger = LoggerFactory.getLogger(ApiController.class);
@Autowired
ConsumerProfileImpl consumerProfileService;
@Autowired
public ApiController(TokenService tokenService, UserRepository userRepository) {
this.tokenService = tokenService;
this.userRepository = userRepository;
}
@RequestMapping(value = "/userLogin", method = {RequestMethod.POST})
public ResponseEntity<?> authenticate(@RequestBody final LoginCommand dto) {
final String token = tokenService.getToken(dto.getUsername(), dto.getPassword());
if (token != null) {
User user = userRepository.findByUsername(dto.getUsername());
final TokenCommand response = new TokenCommand(token, user.getUuid(), user.getAuthorities());
return new ResponseEntity<>(response, HttpStatus.OK);
} else {
ResponseEntity responseEntity = new ResponseEntity<>("Authentication failed", HttpStatus.BAD_REQUEST);
return responseEntity;
}
}
@RequestMapping(value = "/createConsumer", method = {RequestMethod.POST})
public ResponseEntity<?> userSignup(@RequestBody ConsumerProfile consumerProfile) {
ApiSuccessCode response = null;
if (consumerProfileService.save(consumerProfile) != null) {
response = new ApiSuccessCode("200", "Successfully Created");
return new ResponseEntity<>(response, HttpStatus.OK);
}
response = new ApiSuccessCode("201", "Processing Your Request");
return new ResponseEntity<>(response, HttpStatus.ACCEPTED);
}
@GetMapping(value = "/demo")
public String demo() {
logger.info("inside demo ");
return "demo";
}
}
| [
"[email protected]"
] | |
3d89c938dfc149c586c1a5641729f87bd3449a57 | 5741045375dcbbafcf7288d65a11c44de2e56484 | /reddit-decompilada/com/reddit/frontpage/presentation/listing/common/LinkListingScreen$$StateSaver.java | 8f11ce1093f9d06b21c5e157c870347757ec9474 | [] | no_license | miarevalo10/ReporteReddit | 18dd19bcec46c42ff933bb330ba65280615c281c | a0db5538e85e9a081bf268cb1590f0eeb113ed77 | refs/heads/master | 2020-03-16T17:42:34.840154 | 2018-05-11T10:16:04 | 2018-05-11T10:16:04 | 132,843,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,160 | java | package com.reddit.frontpage.presentation.listing.common;
import android.os.Bundle;
import com.evernote.android.state.Bundler;
import com.evernote.android.state.InjectionHelper;
import com.reddit.frontpage.ui.BaseScreen;
import com.reddit.frontpage.ui.BaseScreen$$StateSaver;
import java.util.HashMap;
public class LinkListingScreen$$StateSaver<T extends LinkListingScreen> extends BaseScreen$$StateSaver<T> {
private static final HashMap<String, Bundler<?>> BUNDLERS = new HashMap();
private static final InjectionHelper HELPER = new InjectionHelper("com.reddit.frontpage.presentation.listing.common.LinkListingScreen$$StateSaver", BUNDLERS);
public void save(T t, Bundle bundle) {
super.save((BaseScreen) t, bundle);
HELPER.putInt(bundle, "LastPlayingPosition", t.lastPlayingPosition);
HELPER.putInt(bundle, "LastClickedPosition", t.lastClickedPosition);
}
public void restore(T t, Bundle bundle) {
super.restore((BaseScreen) t, bundle);
t.lastPlayingPosition = HELPER.getInt(bundle, "LastPlayingPosition");
t.lastClickedPosition = HELPER.getInt(bundle, "LastClickedPosition");
}
}
| [
"[email protected]"
] | |
c91aa6c81b717ec176aefec5662d5c83aca4a624 | b5ddf618a0b3865397adee9b29dda323cc86db7d | /week14/src/PrioritySet.java | 896b4b9bf8ab4933e9b18962a7b4c1e9ab94f050 | [
"MIT"
] | permissive | feliciahsieh/javaArchive | 6bcd02244a55eb9ed8fd32c6e222caf52a2a6e7d | 9c0ee7d795486ecfa70f2caee26beaf4aa05540c | refs/heads/master | 2020-03-26T11:47:24.846933 | 2018-08-27T17:02:37 | 2018-08-27T17:02:37 | 144,860,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 606 | java | //for Quiz 12/2/14
import java.util.ArrayList;
public class PrioritySet<T extends Comparable<T> > {
private ArrayList<T> items;
public PrioritySet()
{
items = new ArrayList<T>();
}
void insert(T item)
{
/// TO DO: Implement this method
items.add(item);
}
T getLargest()
{
/// TO DO: Change the class and the code below
/// so this method works.
/// NOTE: You may assume that items is not empty.
T maxItem = items.get(0);
for (int i = 1; i < items.size(); i++)
{
if (items.get(i).compareTo(maxItem) > 0)
maxItem = items.get(i);
}
return maxItem;
}
}
| [
"[email protected]"
] | |
4aa361d006cb3b7800fa9f89c91c78d40b52facc | ca648a0ca63fce9f4de949e70c5ea9b2ae203a55 | /src/main/java/com/lucas/kalah/model/rule/HouseHasSeedsRule.java | a4b20f3a934126e8b9b26eb5f0fad08aa29646c3 | [] | no_license | xlucasdemelo/Kalah | d56c910c9a26b6a1435929085ac46cd22b9dd8af | e8aa31af03fc42c7bc8e37428f3fb00cc17395ea | refs/heads/master | 2022-12-26T15:40:19.039700 | 2020-06-24T01:30:39 | 2020-06-24T01:30:39 | 272,562,661 | 0 | 0 | null | 2020-10-13T23:02:09 | 2020-06-15T23:12:16 | Java | UTF-8 | Java | false | false | 408 | java | package com.lucas.kalah.model.rule;
import com.lucas.kalah.model.game.Game;
import com.lucas.kalah.model.game.Turn;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class HouseHasSeedsRule implements GameRule {
private Game game;
@Override
public Boolean validate(Turn turn) {
return this.game.getBoard().getPits().get(turn.getHouseIndex()).getNumberOfSeeds() > 0;
}
}
| [
"[email protected]"
] | |
2e17dd5fce87850375154fd163bfa0ca1c42fe21 | bbb8bacf0e8eac052de398d3e5d75da3ded226d2 | /emulator_dev/src/main/java/gr/codebb/arcadeflex/WIP/v037b7/cpu/z8000/z8000H.java | 0fd10f4452db03a743198f7d6b21be86e045812c | [] | no_license | georgemoralis/arcadeflex-037b7-deprecated | f9ab8e08b2e8246c0e982f2cfa7ff73b695b1705 | 0777b9c5328e0dd55e2059795738538fd5c67259 | refs/heads/main | 2023-05-31T06:55:21.979527 | 2021-06-16T17:47:07 | 2021-06-16T17:47:07 | 326,236,655 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,566 | java | /*
* ported to v0.37b7
* using automatic conversion tool v0.01
*/
package gr.codebb.arcadeflex.WIP.v037b7.cpu.z8000;
public class z8000H
{
/*TODO*///
/*TODO*/// enum {
/*TODO*/// Z8000_PC=1, Z8000_NSP, Z8000_FCW, Z8000_PSAP, Z8000_REFRESH,
/*TODO*/// Z8000_IRQ_REQ, Z8000_IRQ_SRV, Z8000_IRQ_VEC,
/*TODO*/// Z8000_R0, Z8000_R1, Z8000_R2, Z8000_R3,
/*TODO*/// Z8000_R4, Z8000_R5, Z8000_R6, Z8000_R7,
/*TODO*/// Z8000_R8, Z8000_R9, Z8000_R10, Z8000_R11,
/*TODO*/// Z8000_R12, Z8000_R13, Z8000_R14, Z8000_R15,
/*TODO*/// Z8000_NMI_STATE, Z8000_NVI_STATE, Z8000_VI_STATE };
/* Interrupt Types that can be generated by outside sources */
public static final int Z8000_TRAP = 0x4000; /* internal trap */
public static final int Z8000_NMI = 0x2000; /* non maskable interrupt */
public static final int Z8000_SEGTRAP = 0x1000; /* segment trap (Z8001) */
public static final int Z8000_NVI = 0x0800; /* non vectored interrupt */
public static final int Z8000_VI = 0x0400; /* vectored interrupt (LSB is vector) */
public static final int Z8000_SYSCALL = 0x0200; /* system call (lsb is vector) */
public static final int Z8000_HALT = 0x0100; /* halted flag */
public static final int Z8000_INT_NONE = 0x0000;
/*TODO*/// /* PUBLIC FUNCTIONS */
/*TODO*/// extern unsigned z8000_get_context(void *dst);
/*TODO*/// extern void z8000_set_context(void *src);
/*TODO*/// extern unsigned z8000_get_pc(void);
/*TODO*/// extern void z8000_set_pc(unsigned val);
/*TODO*/// extern unsigned z8000_get_sp(void);
/*TODO*/// extern void z8000_set_sp(unsigned val);
/*TODO*/// extern unsigned z8000_get_reg(int regnum);
/*TODO*/// extern void z8000_set_reg(int regnum, unsigned val);
/*TODO*/// extern void z8000_reset(void *param);
/*TODO*/// extern extern int z8000_execute(int cycles);
/*TODO*/// extern void z8000_set_nmi_line(int state);
/*TODO*/// extern void z8000_set_irq_line(int irqline, int state);
/*TODO*/// extern void z8000_set_irq_callback(int (*callback)(int irqline));
/*TODO*/// extern const char *z8000_info(void *context, int regnum);
/*TODO*/// extern unsigned z8000_dasm(char *buffer, unsigned pc);
/*TODO*///
/*TODO*/// extern void z8000_State_Save(int cpunum, void *f);
/*TODO*/// extern void z8000_State_Load(int cpunum, void *f);
/*TODO*///
/*TODO*/// /* PUBLIC GLOBALS */
/*TODO*/// extern int z8000_ICount;
/*TODO*///
/*TODO*/// #ifdef MAME_DEBUG
/*TODO*/// extern int DasmZ8000(char *buff, int pc);
/*TODO*/// #endif
/*TODO*///
/*TODO*/// #endif /* Z8K_H */
}
| [
"[email protected]"
] | |
5418e25b72355df5ba6cfdd7755697490d57abb5 | 2c9904550377b4741128ca720151885f8d94712e | /src/test/java/com/geeklib/ether/EtherApplicationTests.java | 09981e2f16e83656fb54b671e530443faec94087 | [] | no_license | Geek1st/ether | bf0eb1c4729b0ee720206aa873d2cb122e225a03 | 235ca99ef54002ec74e03fb6b3a888f78b6f2f8e | refs/heads/main | 2023-02-20T01:15:12.621867 | 2021-01-15T14:52:24 | 2021-01-15T14:52:24 | 327,247,553 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 208 | java | package com.geeklib.ether;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class EtherApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
2330567b4147310f87b815ca4c72d6c69fccf61f | 8722c7651d55c5dc84ba086181e24c6ffa05bbbf | /renren-security/renren-admin/src/main/java/io/renren/modules/job/utils/ScheduleJob.java | fec1b320e4c1f471ebed8145a2c52d52e13bbe75 | [
"Apache-2.0"
] | permissive | zqTuo/cake | b115626297f268de6812216e015901ba3e30e23f | 5ee6a8de87e49ea1a04b29aaeaf5f27da4dc430e | refs/heads/master | 2022-07-24T09:23:42.581500 | 2019-10-08T03:29:00 | 2019-10-08T03:29:00 | 211,315,880 | 0 | 0 | null | 2022-07-06T20:42:45 | 2019-09-27T12:36:17 | JavaScript | UTF-8 | Java | false | false | 2,678 | java | /**
*
*
* http://www.xkygame.com
*
* 版权所有,侵权必究!
*/
package io.renren.modules.job.utils;
import io.renren.common.utils.SpringContextUtils;
import io.renren.modules.job.entity.ScheduleJobEntity;
import io.renren.modules.job.entity.ScheduleJobLogEntity;
import io.renren.modules.job.service.ScheduleJobLogService;
import org.apache.commons.lang.StringUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.quartz.QuartzJobBean;
import java.lang.reflect.Method;
import java.util.Date;
/**
* 定时任务
*
* @author Mark [email protected]
*/
public class ScheduleJob extends QuartzJobBean {
private Logger logger = LoggerFactory.getLogger(getClass());
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
ScheduleJobEntity scheduleJob = (ScheduleJobEntity) context.getMergedJobDataMap()
.get(ScheduleJobEntity.JOB_PARAM_KEY);
//获取spring bean
ScheduleJobLogService scheduleJobLogService = (ScheduleJobLogService) SpringContextUtils.getBean("scheduleJobLogService");
//数据库保存执行记录
ScheduleJobLogEntity log = new ScheduleJobLogEntity();
log.setJobId(scheduleJob.getJobId());
log.setBeanName(scheduleJob.getBeanName());
log.setParams(scheduleJob.getParams());
log.setCreateTime(new Date());
//任务开始时间
long startTime = System.currentTimeMillis();
try {
//执行任务
logger.debug("任务准备执行,任务ID:" + scheduleJob.getJobId());
Object target = SpringContextUtils.getBean(scheduleJob.getBeanName());
Method method = target.getClass().getDeclaredMethod("run", String.class);
method.invoke(target, scheduleJob.getParams());
//任务执行总时长
long times = System.currentTimeMillis() - startTime;
log.setTimes((int)times);
//任务状态 0:成功 1:失败
log.setStatus(0);
logger.debug("任务执行完毕,任务ID:" + scheduleJob.getJobId() + " 总共耗时:" + times + "毫秒");
} catch (Exception e) {
logger.error("任务执行失败,任务ID:" + scheduleJob.getJobId(), e);
//任务执行总时长
long times = System.currentTimeMillis() - startTime;
log.setTimes((int)times);
//任务状态 0:成功 1:失败
log.setStatus(1);
log.setError(StringUtils.substring(e.toString(), 0, 2000));
}finally {
scheduleJobLogService.save(log);
}
}
}
| [
"[email protected]"
] | |
f377f91c15011ecb466375d342f4fc00dfb0ccb0 | 652be8c9b1af00c5c28f5b74039ab6ff153decd2 | /hammerchurrasco/hammerchurrasco.Android/obj/Debug/90/android/src/android/support/v7/recyclerview/R.java | 41c1254870c7f048328a9ca3cdf30cbb1f4f17a3 | [] | no_license | aslac2020/churrascohammer | 4db143b7599886ee83809cba9859d9a143caaf46 | 32f65a3c5d5f4fb1f7e864934bfb86de14f790a4 | refs/heads/main | 2023-03-11T04:34:39.302392 | 2021-02-15T04:15:27 | 2021-02-15T04:15:27 | 338,919,311 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,176 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by
* Xamarin.Android from the resource data it found.
* It should not be modified by hand.
*/
package android.support.v7.recyclerview;
public final class R {
public static final class attr {
public static final int alpha = 0x7f030033;
public static final int coordinatorLayoutStyle = 0x7f0300aa;
public static final int fastScrollEnabled = 0x7f0300d5;
public static final int fastScrollHorizontalThumbDrawable = 0x7f0300d6;
public static final int fastScrollHorizontalTrackDrawable = 0x7f0300d7;
public static final int fastScrollVerticalThumbDrawable = 0x7f0300d8;
public static final int fastScrollVerticalTrackDrawable = 0x7f0300d9;
public static final int font = 0x7f0300dc;
public static final int fontProviderAuthority = 0x7f0300de;
public static final int fontProviderCerts = 0x7f0300df;
public static final int fontProviderFetchStrategy = 0x7f0300e0;
public static final int fontProviderFetchTimeout = 0x7f0300e1;
public static final int fontProviderPackage = 0x7f0300e2;
public static final int fontProviderQuery = 0x7f0300e3;
public static final int fontStyle = 0x7f0300e4;
public static final int fontVariationSettings = 0x7f0300e5;
public static final int fontWeight = 0x7f0300e6;
public static final int keylines = 0x7f030112;
public static final int layoutManager = 0x7f030116;
public static final int layout_anchor = 0x7f030117;
public static final int layout_anchorGravity = 0x7f030118;
public static final int layout_behavior = 0x7f030119;
public static final int layout_dodgeInsetEdges = 0x7f03011c;
public static final int layout_insetEdge = 0x7f03011d;
public static final int layout_keyline = 0x7f03011e;
public static final int reverseLayout = 0x7f030158;
public static final int spanCount = 0x7f03016d;
public static final int stackFromEnd = 0x7f030173;
public static final int statusBarBackground = 0x7f030179;
public static final int ttcIndex = 0x7f0301db;
}
public static final class color {
public static final int notification_action_color_filter = 0x7f05006f;
public static final int notification_icon_bg_color = 0x7f050070;
public static final int ripple_material_light = 0x7f05007b;
public static final int secondary_text_default_material_light = 0x7f05007d;
}
public static final class dimen {
public static final int compat_button_inset_horizontal_material = 0x7f060050;
public static final int compat_button_inset_vertical_material = 0x7f060051;
public static final int compat_button_padding_horizontal_material = 0x7f060052;
public static final int compat_button_padding_vertical_material = 0x7f060053;
public static final int compat_control_corner_material = 0x7f060054;
public static final int compat_notification_large_icon_max_height = 0x7f060055;
public static final int compat_notification_large_icon_max_width = 0x7f060056;
public static final int fastscroll_default_thickness = 0x7f060085;
public static final int fastscroll_margin = 0x7f060086;
public static final int fastscroll_minimum_range = 0x7f060087;
public static final int item_touch_helper_max_drag_scroll_per_frame = 0x7f06008f;
public static final int item_touch_helper_swipe_escape_max_velocity = 0x7f060090;
public static final int item_touch_helper_swipe_escape_velocity = 0x7f060091;
public static final int notification_action_icon_size = 0x7f0600c2;
public static final int notification_action_text_size = 0x7f0600c3;
public static final int notification_big_circle_margin = 0x7f0600c4;
public static final int notification_content_margin_start = 0x7f0600c5;
public static final int notification_large_icon_height = 0x7f0600c6;
public static final int notification_large_icon_width = 0x7f0600c7;
public static final int notification_main_column_padding_top = 0x7f0600c8;
public static final int notification_media_narrow_margin = 0x7f0600c9;
public static final int notification_right_icon_size = 0x7f0600ca;
public static final int notification_right_side_padding_top = 0x7f0600cb;
public static final int notification_small_icon_background_padding = 0x7f0600cc;
public static final int notification_small_icon_size_as_large = 0x7f0600cd;
public static final int notification_subtext_size = 0x7f0600ce;
public static final int notification_top_pad = 0x7f0600cf;
public static final int notification_top_pad_large_text = 0x7f0600d0;
}
public static final class drawable {
public static final int notification_action_background = 0x7f070070;
public static final int notification_bg = 0x7f070071;
public static final int notification_bg_low = 0x7f070072;
public static final int notification_bg_low_normal = 0x7f070073;
public static final int notification_bg_low_pressed = 0x7f070074;
public static final int notification_bg_normal = 0x7f070075;
public static final int notification_bg_normal_pressed = 0x7f070076;
public static final int notification_icon_background = 0x7f070077;
public static final int notification_template_icon_bg = 0x7f070078;
public static final int notification_template_icon_low_bg = 0x7f070079;
public static final int notification_tile_bg = 0x7f07007a;
public static final int notify_panel_notification_icon_bg = 0x7f07007b;
}
public static final class id {
public static final int action_container = 0x7f08000e;
public static final int action_divider = 0x7f080010;
public static final int action_image = 0x7f080011;
public static final int action_text = 0x7f080017;
public static final int actions = 0x7f080018;
public static final int async = 0x7f08001e;
public static final int blocking = 0x7f080021;
public static final int bottom = 0x7f080022;
public static final int chronometer = 0x7f080030;
public static final int end = 0x7f080043;
public static final int forever = 0x7f080051;
public static final int icon = 0x7f080056;
public static final int icon_group = 0x7f080057;
public static final int info = 0x7f08005a;
public static final int italic = 0x7f08005b;
public static final int item_touch_helper_previous_elevation = 0x7f08005c;
public static final int left = 0x7f08005f;
public static final int line1 = 0x7f080060;
public static final int line3 = 0x7f080061;
public static final int none = 0x7f080075;
public static final int normal = 0x7f080076;
public static final int notification_background = 0x7f080077;
public static final int notification_main_column = 0x7f080078;
public static final int notification_main_column_container = 0x7f080079;
public static final int right = 0x7f080082;
public static final int right_icon = 0x7f080083;
public static final int right_side = 0x7f080084;
public static final int start = 0x7f0800ab;
public static final int tag_transition_group = 0x7f0800b1;
public static final int tag_unhandled_key_event_manager = 0x7f0800b2;
public static final int tag_unhandled_key_listeners = 0x7f0800b3;
public static final int text = 0x7f0800b4;
public static final int text2 = 0x7f0800b5;
public static final int time = 0x7f0800be;
public static final int title = 0x7f0800bf;
public static final int top = 0x7f0800c3;
}
public static final class integer {
public static final int status_bar_notification_info_maxnum = 0x7f09000e;
}
public static final class layout {
public static final int notification_action = 0x7f0b0033;
public static final int notification_action_tombstone = 0x7f0b0034;
public static final int notification_template_custom_big = 0x7f0b003b;
public static final int notification_template_icon_group = 0x7f0b003c;
public static final int notification_template_part_chronometer = 0x7f0b0040;
public static final int notification_template_part_time = 0x7f0b0041;
}
public static final class string {
public static final int status_bar_notification_info_overflow = 0x7f0d0036;
}
public static final class style {
public static final int TextAppearance_Compat_Notification = 0x7f0e0118;
public static final int TextAppearance_Compat_Notification_Info = 0x7f0e0119;
public static final int TextAppearance_Compat_Notification_Line2 = 0x7f0e011b;
public static final int TextAppearance_Compat_Notification_Time = 0x7f0e011e;
public static final int TextAppearance_Compat_Notification_Title = 0x7f0e0120;
public static final int Widget_Compat_NotificationActionContainer = 0x7f0e01c7;
public static final int Widget_Compat_NotificationActionText = 0x7f0e01c8;
public static final int Widget_Support_CoordinatorLayout = 0x7f0e01f7;
}
public static final class styleable {
public static final int[] ColorStateListItem = new int[] { 0x010101a5, 0x0101031f, 0x7f030033 };
public static final int ColorStateListItem_alpha = 2;
public static final int ColorStateListItem_android_alpha = 1;
public static final int ColorStateListItem_android_color = 0;
public static final int[] CoordinatorLayout = new int[] { 0x7f030112, 0x7f030179 };
public static final int CoordinatorLayout_keylines = 0;
public static final int CoordinatorLayout_statusBarBackground = 1;
public static final int[] CoordinatorLayout_Layout = new int[] { 0x010100b3, 0x7f030117, 0x7f030118, 0x7f030119, 0x7f03011c, 0x7f03011d, 0x7f03011e };
public static final int CoordinatorLayout_Layout_android_layout_gravity = 0;
public static final int CoordinatorLayout_Layout_layout_anchor = 1;
public static final int CoordinatorLayout_Layout_layout_anchorGravity = 2;
public static final int CoordinatorLayout_Layout_layout_behavior = 3;
public static final int CoordinatorLayout_Layout_layout_dodgeInsetEdges = 4;
public static final int CoordinatorLayout_Layout_layout_insetEdge = 5;
public static final int CoordinatorLayout_Layout_layout_keyline = 6;
public static final int[] FontFamily = new int[] { 0x7f0300de, 0x7f0300df, 0x7f0300e0, 0x7f0300e1, 0x7f0300e2, 0x7f0300e3 };
public static final int FontFamily_fontProviderAuthority = 0;
public static final int FontFamily_fontProviderCerts = 1;
public static final int FontFamily_fontProviderFetchStrategy = 2;
public static final int FontFamily_fontProviderFetchTimeout = 3;
public static final int FontFamily_fontProviderPackage = 4;
public static final int FontFamily_fontProviderQuery = 5;
public static final int[] FontFamilyFont = new int[] { 0x01010532, 0x01010533, 0x0101053f, 0x0101056f, 0x01010570, 0x7f0300dc, 0x7f0300e4, 0x7f0300e5, 0x7f0300e6, 0x7f0301db };
public static final int FontFamilyFont_android_font = 0;
public static final int FontFamilyFont_android_fontStyle = 2;
public static final int FontFamilyFont_android_fontVariationSettings = 4;
public static final int FontFamilyFont_android_fontWeight = 1;
public static final int FontFamilyFont_android_ttcIndex = 3;
public static final int FontFamilyFont_font = 5;
public static final int FontFamilyFont_fontStyle = 6;
public static final int FontFamilyFont_fontVariationSettings = 7;
public static final int FontFamilyFont_fontWeight = 8;
public static final int FontFamilyFont_ttcIndex = 9;
public static final int[] GradientColor = new int[] { 0x0101019d, 0x0101019e, 0x010101a1, 0x010101a2, 0x010101a3, 0x010101a4, 0x01010201, 0x0101020b, 0x01010510, 0x01010511, 0x01010512, 0x01010513 };
public static final int GradientColor_android_centerColor = 7;
public static final int GradientColor_android_centerX = 3;
public static final int GradientColor_android_centerY = 4;
public static final int GradientColor_android_endColor = 1;
public static final int GradientColor_android_endX = 10;
public static final int GradientColor_android_endY = 11;
public static final int GradientColor_android_gradientRadius = 5;
public static final int GradientColor_android_startColor = 0;
public static final int GradientColor_android_startX = 8;
public static final int GradientColor_android_startY = 9;
public static final int GradientColor_android_tileMode = 6;
public static final int GradientColor_android_type = 2;
public static final int[] GradientColorItem = new int[] { 0x010101a5, 0x01010514 };
public static final int GradientColorItem_android_color = 0;
public static final int GradientColorItem_android_offset = 1;
public static final int[] RecyclerView = new int[] { 0x010100c4, 0x010100f1, 0x7f0300d5, 0x7f0300d6, 0x7f0300d7, 0x7f0300d8, 0x7f0300d9, 0x7f030116, 0x7f030158, 0x7f03016d, 0x7f030173 };
public static final int RecyclerView_android_descendantFocusability = 1;
public static final int RecyclerView_android_orientation = 0;
public static final int RecyclerView_fastScrollEnabled = 2;
public static final int RecyclerView_fastScrollHorizontalThumbDrawable = 3;
public static final int RecyclerView_fastScrollHorizontalTrackDrawable = 4;
public static final int RecyclerView_fastScrollVerticalThumbDrawable = 5;
public static final int RecyclerView_fastScrollVerticalTrackDrawable = 6;
public static final int RecyclerView_layoutManager = 7;
public static final int RecyclerView_reverseLayout = 8;
public static final int RecyclerView_spanCount = 9;
public static final int RecyclerView_stackFromEnd = 10;
}
}
| [
"[email protected]"
] | |
d5ea59b2d2d43e7ff91feacfc3267e0ceaba42ba | e16f6e939fb90ce2b316c37cba6a942c6be0f2ab | /unittest-springboot-mocking-mockito/src/test/java/com/springbootunittesting/unittestspringbootmockingmockito/ItemControllerIntegrationTest.java | 1cd428b12435d46bd1ffd84b30f5f3472c866b7f | [] | no_license | mpaul7/SpringBoot | 030155955b56c68289fcaa874767acc0f4f831e1 | ba5f3d454bf0756a1f4992a62ba5ff8328c43177 | refs/heads/master | 2022-01-22T09:51:14.877453 | 2019-07-23T18:53:19 | 2019-07-23T18:53:19 | 196,658,131 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,057 | java | package com.springbootunittesting.unittestspringbootmockingmockito;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.skyscreamer.jsonassert.JSONAssert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment=WebEnvironment.RANDOM_PORT)
class ItemControllerIntegrationTest {
@Autowired
private TestRestTemplate restTemplate;
@Test
public void contextLoads() throws JSONException {
String response = this.restTemplate.getForObject("/all-items-from-database", String.class);
JSONAssert.assertEquals("[{id:1001}, {id:1002}, {id:1003}]", response, false);
}
}
| [
"[email protected]"
] | |
8f06ff1b0050ff6d9e5e5afe72f1de39b337d231 | 5bbb90b6e776f9bbb50d251553194bfb74a1b042 | /src/main/java/com/crsri/mes/service/ProducePartsDefendService.java | e85eb93d78c954d85ec9f302fe4abbcd189606c9 | [] | no_license | 1003144387/mes | 468b2e6761362954e532cb5ef0fadc0e5c4d16c6 | b3bc5140644dd5b48f10d28df705d425feeb4bb7 | refs/heads/master | 2023-08-11T18:35:57.482694 | 2019-06-28T10:45:13 | 2019-06-28T10:45:13 | 194,256,882 | 0 | 0 | null | 2023-07-22T09:31:34 | 2019-06-28T10:42:01 | TSQL | UTF-8 | Java | false | false | 676 | java | package com.crsri.mes.service;
import com.crsri.mes.common.response.ServerResponse;
import com.crsri.mes.vo.ProducePartsDefendApproveVO;
/**
* 生产部件三防审批的service接口
*
* @author 2011102394
*
*/
public interface ProducePartsDefendService {
/**
* 新增生产部件三防审批
*
* @param partsDefendApproveVO
* @return
*/
ServerResponse save(ProducePartsDefendApproveVO partsDefendApproveVO);
/**
* 处理生产部件三防审批的审批结果
* @param processInstanceId
* @param approveStatus
* @param approveResult
*/
void handleApproveCallBack(String processInstanceId, Integer approveStatus, Integer approveResult);
}
| [
"[email protected]"
] | |
baaaec805858a9708374da01c3442449b1ac35ee | 816253c03f7a8aedcf6f793a24408e2753d6ba4f | /src/com/sie/dto/Stoke.java | 72267a3cdedae9220a77ed97d1b8c07a22be048a | [] | no_license | zarhell/ReporteJasperP | 7546dabcaf2cbe02aed6e86bea46868048f17d07 | 613e43c9137dcda27add5407f362e7569ff1ba32 | refs/heads/master | 2020-03-23T19:36:03.905470 | 2018-07-23T14:22:25 | 2018-07-23T14:22:25 | 141,990,172 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | /**
* @author B13rayan
* @date 19-may-2018
* @time 20:28:46
*/
package com.sie.dto;
public class Stoke {
private Integer id;
private String nombre;
private String descripcion;
private Integer cantidad;
private Integer idsede;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
public Integer getCantidad() {
return cantidad;
}
public void setCantidad(Integer cantidad) {
this.cantidad = cantidad;
}
public Integer getIdsede() {
return idsede;
}
public void setIdsede(Integer idsede) {
this.idsede = idsede;
}
}
| [
"Zarhell@Zrz"
] | Zarhell@Zrz |
b175669632c4307757628f5cf62631264cb88c1f | 3ac81dfbf27732ab3c4032f160f052a50144a384 | /Java_0714/src/Day05/Day05_3.java | 586402cc1dbe67ae123fa5a63fa22ee11a035e00 | [] | no_license | haaaran/java_1 | 4b4264e78b24b18734d5fe54cf00470bc320b51a | ef8cd6e2c95df54ef3be7f6d0120e1df4f65c193 | refs/heads/master | 2023-06-20T17:56:45.054050 | 2021-07-27T07:02:46 | 2021-07-27T07:02:46 | 387,408,169 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 2,528 | java | package Day05;
import java.util.Scanner;
public class Day05_3 {//c s
public static void main(String[] args) {//m s
Scanner scanner = new Scanner(System.in);
// 별 문제 6
System.out.print("줄6 개수 : "); int 줄6 = scanner.nextInt();
for( int i6 = 1 ; i6<=줄6 ; i6++ ) {
// 공백 찍기
for( int b6= 1; b6<=i6-1 ; b6++ ) {System.out.print(" ");}
// 별 찍기
for( int s6= 1; s6<=줄6-i6+1 ; s6++){System.out.print("*");}
// 줄 바꿈
System.out.println();
}
System.out.println("\n-----------------------------------------------");
// 별 문제7 피라미드
System.out.print("줄7 개수 : "); int 줄7 = scanner.nextInt();
for( int i7 = 1 ; i7<=줄7 ; i7++ ) {
// 공백 찍기
for( int b7= 1; b7<=줄7-i7 ; b7++ ) {System.out.print(" ");}
// 별 찍기
for( int s7= 1; s7<=i7*2-1 ; s7++){System.out.print("*");}
// 줄 바꿈
System.out.println();
}
System.out.println("\n-----------------------------------------------");
//별 문제8 숫자 피라미드
System.out.print("줄8 개수 : "); int 줄8 = scanner.nextInt();
for( int i8 = 1 ; i8<=줄8 ; i8++ ) {
// 공백 찍기
for( int b8= 1; b8<=줄8-i8 ; b8++ ) {System.out.print(" ");}
// 숫자 찍기
for( int s8= 1; s8<=i8*2-1 ; s8++){System.out.print(i8);}
// 줄 바꿈
System.out.println();
}
System.out.println("\n-----------------------------------------------");
//별 문제9 역순 피라미드
System.out.print("줄9 개수 : "); int 줄9 = scanner.nextInt();
for( int i9 = 1 ; i9<=줄9 ; i9++ ) {
// 공백 찍기
for( int b9= 1; b9<=i9-1 ; b9++ ) {System.out.print(" ");}
// 별 찍기
for( int s9= 1; s9<=(줄9-i9+1)*2-1 ; s9++){System.out.print("*");}
// 줄 바꿈
System.out.println();
}
// 별 문제10 피라미드
System.out.print("줄10 개수 : "); int 줄10 = scanner.nextInt();
for( int i = 1 ; i<=줄10 ; i++ ) {
// 공백 찍기
for( int b= 1; b<=줄10-i ; b++ ) {System.out.print(" ");}
// 별 찍기
for( int s= 1; s<=i*2-1 ; s++){System.out.print("*");}
// 줄 바꿈
System.out.println();
}
// 공백 찍기
for( int i = 1 ; i<=줄10 ; i++ ) {
for( int b= 1; b<=i-1 ; b++ ) {System.out.print(" ");}
// 별 찍기
for( int s= 1; s<=(줄10-i+1)*2-1 ; s++){System.out.print("*");}
System.out.println();
}
}//m e
}//c e
| [
"현우@DESKTOP-320B0LH"
] | 현우@DESKTOP-320B0LH |
be7cbf031bc9a41634b520d96bc0fb9b6220a98f | 4b0de4866bfa0d7db21208e0e0d9a9e12f3050a3 | /app/src/main/java/id/ac/pcr/projekku/MainActivity.java | 458ef371f24c3806238081f15e83a1af09a045c7 | [] | no_license | haiqaldani/projek-fitri | 10dbf018f60e5c1850a4585d885b2a4f2fbe3b5c | 3e548a4f16258181222d8ea33411aa15552e3f24 | refs/heads/main | 2023-06-27T10:00:45.253633 | 2021-07-31T10:54:54 | 2021-07-31T10:54:54 | 390,767,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 948 | java | package id.ac.pcr.projekku;
import android.content.Intent;
import android.os.Handler;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import id.ac.pcr.projekku.preference.SharedPrefManager;
public class MainActivity extends AppCompatActivity {
private SharedPrefManager sharedPrefManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sharedPrefManager = new SharedPrefManager(MainActivity.this);
setContentView(R.layout.activity_main);
int waktu_loading = 2500;
new Handler().postDelayed(() -> {
if (sharedPrefManager.getSPSudahLogin()) {
startActivity(new Intent(MainActivity.this, dashboard.class));
} else {
startActivity(new Intent(MainActivity.this, LoginActivity.class));
}
finish();
}, waktu_loading);
}
}
| [
"[email protected]"
] | |
b45c9401419b5c8ed6d0ca33c8cca4fe343d3a4e | a81bec1ac259a155f4fae8f54d66379d12b3127e | /UI_ListView_SingleChoice/gen/com/example/c7_1_listview_singlechoice/BuildConfig.java | 1d264162fd0dcfc6e6c5cd7a0ef493c2e568ef27 | [] | no_license | comeonbaby2015/android_suddy_demo | 36d5cef0ba373074ed421f139b15e1b14fd38af5 | 5df724bdf80ca5b562d66b48396a14a51e6ef0f0 | refs/heads/master | 2016-08-11T15:46:36.399608 | 2016-01-03T14:54:45 | 2016-01-03T14:54:45 | 48,948,451 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 180 | java | /** Automatically generated file. DO NOT MODIFY */
package com.example.c7_1_listview_singlechoice;
public final class BuildConfig {
public final static boolean DEBUG = true;
} | [
"[email protected]"
] | |
fcf465ff0e130e4d09700589b757176d8dc9f0c9 | de5b1f6212d5dd92d033f5dafffd40ac56bb1ee6 | /src/main/java/com/edmar/apiRestConductor/repository/ContaRepository.java | 2e9f16685ec8d4945a2113afcae9b68525eeefd7 | [] | no_license | fabiansilva2/apiContaBancaria | afbe3d79c7623aa6e3ae549edaa4739338314b33 | f9c46e4edecdbf31b5ba0f06cf1cda1d0e095e87 | refs/heads/master | 2023-03-16T12:08:40.515017 | 2018-06-18T15:13:15 | 2018-06-18T15:13:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 824 | java | package com.edmar.apiRestConductor.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import com.edmar.apiRestConductor.model.Conta;
@Transactional(readOnly = false)
public interface ContaRepository extends JpaRepository<Conta, Long>{
//Conta findByPessoaIdPessoa(@Param("idPessoa") Long pessoaId);
@Modifying
@Query("update Conta c set c.saldo = c.saldo + ?1 where c.idConta = ?2")
void setFixedSaldoFor(double quantidade, Long id);
Conta findByIdConta(Long id);
@Modifying
@Query("update Conta c set c.saldo = c.saldo - ?1 where c.idConta = ?2")
void setFixedSaldo(double quant, Long id);
}
| [
"[email protected]"
] | |
26b9f0e327dfb09128055ee2302b355586e5d19c | 930c38c3becee0da463fdfc3c3e0d232b7fe1e32 | /src/main/java/com/leetcode/other/P23_BasicCalculatorII.java | 441dcc92ca88711f28733a63485c648eb9fdf8b7 | [] | no_license | Jemmm1992/jemmmCode | 58920f0de233c75555a444ae2688216ae78bed9a | 415b89755959930baebdc674f277cd442cbe0085 | refs/heads/master | 2020-04-05T14:34:13.597278 | 2017-09-26T14:42:32 | 2017-09-26T14:42:32 | 94,686,638 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,068 | java | package com.leetcode.other;
import java.util.Stack;
/**
* Created by BIG-JIAN on 2017/7/28.
*/
public class P23_BasicCalculatorII {
public static void main(String[] args) {
String s = "12+3*4+10";
System.out.println(calculate(s));
}
public static int calculate(String s) {
Stack<Integer> stack = new Stack<>();
int res = 0, num = 0;
char op = '+';
char[] cArray = s.toCharArray();
for (int i = 0; i < cArray.length; i++) {
char c = cArray[i];
if (c >= '0' && c <= '9') num = num * 10 + c - '0';
if (c == '+' || c == '-' || c == '*' || c == '/' || i == cArray.length - 1) {
if (op == '-') stack.push(-num);
if (op == '+') stack.push(num);
if (op == '*') stack.push(stack.pop() * num);
if (op == '/') stack.push(stack.pop() / num);
op = c;
num = 0;
}
}
for (int i : stack) {
res += i;
}
return res;
}
}
| [
"[email protected]"
] | |
aa84c0d0ae1a11589ffc4ac2012ee632c5043947 | 7480002c087993f255c6ea78591d66828df7a1b9 | /app/src/main/java/com/bibiweather/android/gson/Weather.java | ae37eab28957a1369570d12d081414e01bbea490 | [
"Apache-2.0"
] | permissive | menyiDoorOne/bibiweather | 1a396cc5aef2f3882a9e3ef1bb240e214c947377 | 574bdbff27f4fa45727a035b5348f099a12e0c1c | refs/heads/master | 2020-03-18T14:09:29.176039 | 2018-06-10T13:02:37 | 2018-06-10T13:02:37 | 134,833,062 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 388 | java | package com.bibiweather.android.gson;
import com.google.gson.annotations.SerializedName;
import java.util.List;
/**
* Created by 门一 on 2018/5/26.
*/
public class Weather {
public String status;
public Basic basic;
public AQI aqi;
public Now now;
public Suggestion suggestion;
@SerializedName("daily_forecast")
public List<Forecast> forecastList;
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.