id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
c105fbb2-932d-4fab-aafa-c857edd2256a | @Test(expected = NotEnoughMoneyInATM.class)
public void checkMoneyEnoughInATMThrowsException()
throws NotEnoughMoneyInATM, NotEnoughMoneyInAccount {
double ammount = 500;
double moneyInATM = 200;
double accountBalance = 1000;
Account acc = mock(Account.class);
Card card = mock(Card.class);
ATM atm = new... |
89a0bd51-5784-43b1-9521-44b3cdffc9b4 | @Test
public void getInCorrectOrderCashMethod() throws NotEnoughMoneyInAccount,
NotEnoughMoneyInATM {
Account acc = mock(Account.class);
Card card = mock(Card.class);
ATM atm = new ATM(acc, card);
double ammount = 500.0;
double accountBalance = 700;
double moneyFromATM = 1000;
when(acc.getBalance()).t... |
bbdd11f4-60c0-4f47-b5fd-a9610eecea60 | public void f() throws NotEnoughMoneyInATM {
System.out.println(
"Throwing NotEnoughMoneyInATM");
throw new NotEnoughMoneyInATM ();
} |
de783539-d430-4673-a628-02e9abaa41b3 | public static void main(String[] args) {
NotEnoughMoneyInATMDemo sed =
new NotEnoughMoneyInATMDemo();
try {
sed.f();
} catch(NotEnoughMoneyInATM e) {
System.err.println("Caught it!");
}
} |
61604f5a-a742-4909-af12-631adb4c7c4a | public void f() throws NotEnoughMoneyInAccount {
System.out.println(
"Throwing NotEnoughMoneyInAccount");
throw new NotEnoughMoneyInAccount ();
} |
81f052e3-9f9b-4382-a7f0-1177570c792b | public static void main(String[] args) {
NotEnoughMoneyInAccountDemo sed =
new NotEnoughMoneyInAccountDemo();
try {
sed.f();
} catch(NotEnoughMoneyInAccount e) {
System.err.println("Caught it!");
}
} |
027f12f1-1c33-480a-bf9d-b5fa11e73aaa | public void f() throws NoCardInserted {
System.out.println(
"Throwing NoCardInserted");
throw new NoCardInserted ();
} |
9d30768a-7b2c-457e-8d8c-f706e5faed5a | public static void main(String[] args) {
NoCardInsertedDemo sed =
new NoCardInsertedDemo();
try {
sed.f();
} catch(NoCardInserted e) {
System.err.println("Caught it!");
}
} |
045685ff-fd56-410b-872a-afd440215523 | public ISAACAlgorithm() {
mem = new int[SIZE];
rsl = new int[SIZE];
init(false);
} |
40848f26-df75-4aa4-a515-7c8bc805db38 | public ISAACAlgorithm(int[] seed) {
mem = new int[SIZE];
rsl = new int[SIZE];
// This is slow and throws an ArrayIndexOutOfBoundsException if
// seed.length > rsl.length ...
/* for (int i = 0; i < seed.length; ++i) rsl[i] = seed[i]; */
// ... this is faster and safe:
System.arraycopy(seed, 0, rsl, 0,
... |
127bb504-4504-40e7-b6c5-8f9ca51d3b72 | private final void isaac() {
int i, x, y;
b += ++c;
for (i = 0; i < SIZE; ++i) {
x = mem[i];
switch (i & 3) {
case 0:
a ^= a << 13;
break;
case 1:
a ^= a >>> 6;
break;
case 2:
a ^= a << 2;
break;
case 3:
a ^= a >>> 16;
break;
}
a += mem[i + SIZE / 2 & SIZE ... |
6a85daa7-f845-49cd-b126-e08595e902ba | private final void init(boolean flag) {
int i;
int a, b, c, d, e, f, g, h;
a = b = c = d = e = f = g = h = 0x9e3779b9; // The golden ratio
for (i = 0; i < 4; ++i) {
a ^= b << 11;
d += a;
b += c;
b ^= c >>> 2;
e += b;
c += d;
c ^= d << 8;
f += c;
d += e;
d ^= e >>> 16;
g += d;
... |
d7e6f4b6-3ab0-4e90-b2a4-9f26acb4a03e | public final int nextInt() {
if (0 == count--) {
isaac();
count = SIZE - 1;
}
return rsl[count];
} |
67321ca2-6f04-4432-94ec-bbb841fc2159 | final void supplementSeed(int[] seed) {
for (int i = 0; i < seed.length; i++)
mem[i % mem.length] ^= seed[i];
} |
2b4bece4-2bcb-4017-8d80-edada86787d0 | public static void main(String[] args) {
logger.info("Starting the server application...");
// we load the networking related stuff now
try {
new GameServerBootstrap().bind();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
5f326bfc-2d32-4cc6-a306-a7025134c0e9 | @Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline p = Channels.pipeline();
return p;
} |
25af8dde-5938-454f-82ed-33ffe0e1c16a | public GameServerBootstrap() throws IOException {
} |
d3e9d1bc-bc9d-484e-8b8f-883e5b476757 | public void bind() {
logger.info("Starting the networking...");
// We set the netty up now
bootstrap.setFactory(new NioServerSocketChannelFactory(executor, executor));
bootstrap.setPipelineFactory(new GameServerPipelineFactory());
// The address the server will be listening too
SocketAddress game = ne... |
e2d681be-0bd0-4fc9-afac-1a94d6efd929 | public Entity(int index) {
this.index = index;
} |
813f403c-0f4e-41ff-8178-25da652f8fb1 | public final int getIndex() {
return index;
} |
862f8d15-aec5-4c19-8a55-80ae58d15ef4 | public Position getPosition() {
return position;
} |
76169eb1-1b76-4b7e-aa68-2ee6252c1b2d | public void setPosition(Position position) {
this.position = position;
} |
4a909cd2-67ef-40a2-886f-9f84657de692 | private GameConstants() {
} |
e278d895-60af-436d-8b93-67a1d0f6c91d | public Position(int x, int y, int z) {
this.x = (short)x;
this.y = (short)y;
this.z = (byte)z;
} |
1788a314-169d-4069-b1f1-6bad33f319e9 | public short getX() {
return x;
} |
aca81606-dbbf-448d-b91d-d877c2e0b594 | public short getY() {
return y;
} |
cd528e01-412d-40c7-a124-809abd359371 | public byte getZ() {
return z;
} |
9f8424e2-296a-4e1b-bcde-0f63bde72095 | public boolean isUpdateRequired() {
return !flags.isEmpty();
} |
dc1dabca-edc4-4a0c-81c0-60357c97ae72 | public Combatable(int index) {
super(index);
// TODO Auto-generated constructor stub
} |
7f990212-1147-4adc-aa0f-46f97e26d4bb | public Actor(int index) {
super(index);
// TODO Auto-generated constructor stub
} |
5b7bab8e-82bb-4949-8a3c-1bf7bf753a2d | public Player(int index) {
super(index);
// TODO Auto-generated constructor stub
} |
920a0684-fe74-4e34-96fe-e433a67774a9 | public Mob(int index) {
super(index);
// TODO Auto-generated constructor stub
} |
6a45d01b-25f1-49f7-9273-c85c97fd48a5 | public CombatableMob(int index) {
super(index);
// TODO Auto-generated constructor stub
} |
57194d5d-1db0-40dc-8e51-6d761b722c3f | public static void main(String[] args) {
// TODO Auto-generated method stub
ClientLoginFrame clientLoginFrame=new ClientLoginFrame();
clientLoginFrame.setSize(450,300);
clientLoginFrame.setVisible(true);
clientLoginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
} |
e869ea8a-65e3-4b3c-b14a-e268d52bcaa3 | public ClientLoginFrame() {
getContentPane().setLayout(null);
System.out.println("Want to connect to Server?");
panel = new JPanel();
panel.setBounds(40, 41, 349, 186);
getContentPane().add(panel);
panel.setLayout(null);
JLabel lblIpAddress = new JLabel("Ip Address");
lblIpAddress.setBounds(31, 36, 81,... |
b327a187-66e2-4172-8cb5-a301eea4060c | public void actionPerformed(ActionEvent arg0) {
String ipAddress = textField.getText();
String name = txtRakin.getText();
int port = Integer.parseInt(tfPort.getText());
try {
System.out.println("Trying to connect to Server.");
Socket socket = new Socket(ipAddress, port);
System.out.prin... |
6fc3fd82-fcff-4048-8e86-4efa020e167f | public ClientFrame(final Socket socket) {
getContentPane().setLayout(null);
this.socket = socket;
fileChooser = new JFileChooser();
fileChooser.setMultiSelectionEnabled(true);
folderChooser = new JFileChooser();
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
folderChooser.setMultiSel... |
c0f5495d-d076-41ae-a869-eecc8e7b303e | public void actionPerformed(ActionEvent e) {
String[] paths = tfFilePath.getText().split(";");
try {
for (String path : paths) {
OutputStream os = socket.getOutputStream();
DataOutputStream dos = new DataOutputStream(os);
dos.writeUTF("ConfigurationRequest");
DataInputStream di... |
eb9d9010-fe0c-47d8-b5d2-1ed9f53d3576 | public void actionPerformed(ActionEvent arg0) {
String path = tfFolderPath.getText();
// FileInputStream fis = null;
try {
OutputStream os = socket.getOutputStream();
DataOutputStream dos = new DataOutputStream(os);
dos.writeUTF("ConfigurationRequest");
DataInputStream dis = ne... |
5f7dbbce-1476-471d-a3d1-c6c0cc2b9899 | public void actionPerformed(ActionEvent arg0) {
if (fileChooser.showOpenDialog(getFrames()[0]) == JFileChooser.APPROVE_OPTION) {
tfFilePath.setText(getAllFileName(fileChooser.getSelectedFiles()));
}
} |
0e8fd0c1-1946-40df-b010-53721d9760e7 | public void actionPerformed(ActionEvent arg0) {
if (folderChooser.showOpenDialog(getFrames()[0]) == JFileChooser.APPROVE_OPTION) {
tfFolderPath.setText(folderChooser.getSelectedFile()
.getAbsolutePath());
}
} |
50f01eec-fe43-4543-a30f-348aa300345c | private void transmitFile(String path) throws Exception {
// TODO Auto-generated method stub
int read = 0, firstByte = 0;
File file = new File(path);
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bufStream = new BufferedInputStream(fis);
OutputStream os = socket.getOutputStream();... |
00db772e-b9a9-4e50-9606-38201f3633fd | private void transmitFolder(String path) throws Exception {
File fileOrDir = new File(path);
// System.out.println(path);
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
String absolutePath = fileOrDir.getAbsolutePath();
if (fileOrDir.isDirectory()) {
dos.writeUTF("Folder");
dos.... |
5c568ec1-10a9-4777-af8f-76cd6ee34c99 | private String getAllFileName(File[] selectedFiles) {
// TODO Auto-generated method stub
String allNames="";
int count=0;
for (File f : selectedFiles) {
allNames+=f.getAbsolutePath();
if(count!=selectedFiles.length)allNames+=";";
count++;
}
return allNames;
} |
ed5992ac-abe8-4088-af53-1e8359a76fc5 | public ClientThread(String ipAddress, String name) {
super();
this.ipAddress = ipAddress;
this.name = name;
} |
1bb4d0b6-1d2e-4494-bf8d-483d7fdf3c52 | @Override
public void run() {
// TODO Auto-generated method stub
} |
8dff6258-3106-4dbd-997f-f0714da90674 | public Configurations() {
} |
f3131ce4-058a-4034-a343-d8eb7089fcba | public String getRootPath() {
return rootPath;
} |
d542902c-f567-4f8b-8479-55938f6e6eea | public void setRootPath(String rootPath) {
this.rootPath = rootPath;
} |
d84560c9-147c-4467-b655-064625c7a4ef | public String[] getExtensions() {
return extensions;
} |
d070686e-c13c-42c5-81bf-308d91d25338 | public void setExtensions(String[] extensions) {
this.extensions = extensions;
} |
00808b1e-b5c8-40ed-803d-535cb412027e | public int getNumberOfFiles() {
return numberOfFiles;
} |
be1ae64d-e173-4f21-92dc-a10e4ea3f71a | public void setNumberOfFiles(int numberOfFiles) {
this.numberOfFiles = numberOfFiles;
} |
dcdd0687-3a00-452d-ab50-f642e1c13567 | public Long getMaximumSize() {
return maximumSize;
} |
85603d0a-4d86-4185-8679-4af8e5acfeeb | public void setMaximumSize(Long maximumSize) {
this.maximumSize = maximumSize;
} |
49e79313-98cf-4aed-ba68-c7741c280a01 | public Long getMinId() {
return minId;
} |
7578fbb6-fa23-407a-820e-05a2f1746465 | public void setMinId(Long minId) {
this.minId = minId;
} |
3fa5dc53-5151-49f8-87c9-0e2ee0ba21b4 | public Long getMaxId() {
return maxId;
} |
08ad646f-ae28-4e7a-bd57-e17d2ee65181 | public void setMaxId(Long maxId) {
this.maxId = maxId;
} |
0512345d-fa7d-4bc9-b42e-82f81dfe908c | public boolean isFolderAllowed() {
return folderAllowed;
} |
6f7bb7d1-a5c8-4a15-ad0e-23eeb1bd0fae | public void setFolderAllowed(boolean folderAllowed) {
this.folderAllowed = folderAllowed;
} |
caa317ec-da3f-4ecd-baa4-c3cc4360b5ed | public Configurations(String rootPath, String[] extensions,
int numberOfFiles, Long maximumSize, Long minId, Long maxId,
boolean folderAllowed) {
super();
this.rootPath = rootPath;
this.extensions = extensions;
this.numberOfFiles = numberOfFiles;
this.maximumSize = maximumSize;
this.minId = minId;
t... |
3b682c25-04c1-4943-b2ff-d0dd373708ae | @Override
public String toString() {
return "Configurations [rootPath=" + rootPath + ", extensions="
+ Arrays.toString(extensions) + ", numberOfFiles="
+ numberOfFiles + ", maximumSize=" + maximumSize + ", minId="
+ minId + ", maxId=" + maxId + ", folderAllowed="
+ folderAllowed + "]";
} |
d646942c-4797-4b2b-9518-b33305543ad7 | public boolean isValidExtension(String fileName)
{
for (String s : extensions) {
if(fileName.endsWith(s)) return true;
}
return false;
} |
8bc430c8-85a3-484c-a217-33f508e81a25 | public boolean isValidSize(Long fileSize)
{
if(fileSize<=maximumSize)return true;
return false;
} |
8b5fdde5-9df8-4dea-aaa4-915b310498fa | public boolean isValidStudentId(Long studentId)
{
if(studentId>=minId && studentId<=maxId)return true;
return false;
} |
c47692b8-2c6b-4f19-891d-f4288486db56 | public boolean isValidIpAddress(Long studentId,InetAddress ipAddress)
{
InetAddress requiredIpAddress= (InetAddress)ServerRunningFrame.ipIdMap.get(studentId);
if(requiredIpAddress==null)
{
return false;
}
else if(requiredIpAddress.equals(ipAddress))
{
return true;
}
return false;
} |
09ce6ab5-7dd0-491c-b3b9-ca377ed6992c | public void insertNewIdIpMap(Long studentId,InetAddress inetAddress)
{
if(ServerRunningFrame.ipIdMap.containsValue(inetAddress))
{
return;
}
else
{
ServerRunningFrame.ipIdMap.put(studentId, inetAddress);
ServerRunningFrame.idNumOfFilesMap.put(studentId,0);
}
} |
d85a2cd7-104f-4771-bd38-746998ada622 | public boolean isValidFileCount(int count)
{
return count<numberOfFiles;
} |
c3b38c20-e649-49fd-abf8-50d46bb59573 | public static String md5(InputStream is) throws IOException {
String md5 = "";
try {
byte[] bytes = new byte[4096];
int read = 0;
MessageDigest digest = MessageDigest.getInstance("MD5");
while ((read = is.read(bytes)) != -1) {
digest.up... |
8ab1c7e7-bd52-4372-a5b4-91dca0438ca6 | public FileOrFolderRecieverThread(Socket socket, Long studentId,
Configurations configurations) throws Exception {
this.configurations = configurations;
this.studentId = studentId;
this.socket = socket;
bufStream = new BufferedInputStream(socket.getInputStream());
dis = new DataInputStream(bufStream);
} |
479ebfe1-6f45-42d5-86bb-52b7e759a145 | @Override
public void run() {
// TODO Auto-generated method stub
try {
while (true) {
while (bufStream.available() == 0) {
}
String configreq = dis.readUTF();
ServerRunningFrame.println(configreq);
if (configreq.equals("ConfigurationRequest")) {
DataOutputStream dOutputStream = new ... |
611c80a4-99df-4bfc-9391-6ea45388a452 | private void recieveFile(String abstractPath) throws Exception {
// TODO Auto-generated method stub
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
// check overwrite
String fileNameString = dis.readUTF();
if (fileExists(abstractPath, fileNameString)) {
dos.writeUTF("Exists");
w... |
4962b09a-37e7-48ee-8e64-f88204b9c2a9 | private boolean isEqualChecksum(InputStream fos, String checkSum)
throws Exception {
// TODO Auto-generated method stub
String curCheckSum = Checksum.md5(fos);
System.out.println(checkSum);
System.out.println(curCheckSum);
return curCheckSum.equals(checkSum);
} |
2189f910-17dd-4d2c-a406-972ca31c16b8 | private void recieveFolder(String abstractPath) throws Exception {
// TODO Auto-generated method stub
while (bufStream.available() == 0) {
}
String choice = dis.readUTF();
System.out.println(choice);
if (choice.equals("Folder")) {
String folderName = dis.readUTF();
System.out.println(folderName);
... |
279e44a3-4e01-4afe-87f4-67a3939a34c0 | public boolean fileExists(String abstractpath, String fileName) {
File directory = new File(abstractpath + File.separator + fileName);
return directory.exists();
} |
caed1707-763a-4b99-8f54-0001a64a34c4 | public ServerRunningFrame(Configurations configurations) {
getContentPane().setLayout(null);
this.configurations = configurations;
setSize(500, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
thread = new Thread(this);
JPanel panel = new JPanel();
panel.setBorder(new EmptyBor... |
c84da801-d3c7-46f9-aafd-b75fff7f873c | @Override
public void run() {
// TODO Auto-generated method stub
ipIdMap = new HashMap<Long, InetAddress>();
idNumOfFilesMap= new HashMap<Long, Integer>();
Random random = new Random();
int port = random.nextInt(64000);
try {
System.out.println("Connecting to server socket at port " + port);
textAr... |
b61fb356-c6f3-44dc-98e8-f3f69b415859 | public static void println(String s) {
textArea.append(s + "\n");
} |
43333bad-3ef0-4c7b-a71c-5ebf23c30dcd | public ServerConfigurationFrame() {
getContentPane().setLayout(null);
jFileChooser= new JFileChooser();
jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
JPanel panel = new JPanel();
panel.setBounds(10, 11, 464, 313);
getContentPane().add(panel);
panel.setLayout(null);
JLabel lb... |
e36f6ac6-4a84-43a7-b9e9-deaf8839f5e8 | public void actionPerformed(ActionEvent e) {
if (jFileChooser.showOpenDialog(getFrames()[0]) == JFileChooser.APPROVE_OPTION) {
tfRootDirectory.setText(jFileChooser.getSelectedFile()
.getAbsolutePath());
}
} |
e7091de5-b243-4b6b-a8c1-c5fe6febeb9c | public void actionPerformed(ActionEvent e) {
if(tfFileTypes.getText().equals(""))
tfFileTypes.setText(tfNewType.getText());
else tfFileTypes.setText(tfFileTypes.getText()+";"+tfNewType.getText());
tfNewType.setText("");
} |
fcf2cd2b-35a0-4209-bc32-4f4246af32c9 | public void actionPerformed(ActionEvent arg0) {
String rootPath=tfRootDirectory.getText();
String fileType=tfFileTypes.getText();
String[] extensions=fileType.split(";");
int numberOfFiles=Integer.parseInt(tfNumbeOfFiles.getText());
long maxFileSize= Long.parseLong(tfFileSize.getText());
lo... |
e1144b95-52ad-4f57-a7d5-5e65ff706090 | public static void main(String[] args) {
// TODO Auto-generated method stub
ServerConfigurationFrame serverConfigurationFrame= new ServerConfigurationFrame();
serverConfigurationFrame.setSize(500,400);
serverConfigurationFrame.setVisible(true);
serverConfigurationFrame.setDefaultCloseOperation(JFrame... |
81b6e791-a3ce-4960-9b6a-94387fe08f77 | void conversationCreated(Conversation conversation); |
1e0bc4b1-bb4c-4216-99c1-628cbf0bd8ba | void conversationResuming(Conversation conversation, HttpServletRequest request); |
50deb7ce-5433-4ecf-bc5f-87692e7e2ce5 | void conversationPausing(Conversation conversation); |
6dc93e37-77c6-43c9-8580-f2d66fab0801 | void conversationEnding(Conversation conversation); |
5fe9ed91-2d15-41a6-abb9-aa0e85be5e41 | public ConversationCallBack() {
} |
5470c0cd-e10b-4edf-80a9-94210f0fc062 | public final String ok(T entity) {
incrementPopContextOnNextPauseCounter();
onOk(entity);
return nextView();
} |
eccf660d-a7ee-423c-ba6a-6d5c3b701d38 | protected void onOk(T entity) {
} |
abebb10f-ed34-47bb-bbff-bf1076d98a34 | public final String selected(T entity) {
incrementPopContextOnNextPauseCounter();
onSelected(entity);
return nextView();
} |
1f2acef5-8308-48dd-af15-832fdf2f3737 | public final String selected(T... entities) {
incrementPopContextOnNextPauseCounter();
for (T entity : entities) {
onSelected(entity);
}
return nextView();
} |
8e818f2c-aac4-4526-8cc5-4f9214b92f13 | protected void onSelected(T entity) {
} |
62d5f6ce-4847-4b95-a5a4-bd8c211d72bf | public final String saved(T entity) {
incrementPopContextOnNextPauseCounter();
onSaved(entity);
return nextView();
} |
f68d3d83-84dc-4f0d-b167-66b21db7a54b | protected void onSaved(T entity) {
} |
cc3596f4-75c7-4994-a649-aa0eef2075b0 | public final String notSaved(T entity) {
incrementPopContextOnNextPauseCounter();
onNotSaved(entity);
return nextView();
} |
8e40be65-c326-40dd-8a6a-1d2dc2b93190 | protected void onNotSaved(T entity) {
} |
6a5b22ac-09dd-4ddc-a8a6-1da47c265b0a | public final String deleted(T entity) {
incrementPopContextOnNextPauseCounter();
onDeleted(entity);
return nextView();
} |
ae87a7f8-0e55-407d-8e1c-10f158b88527 | protected void onDeleted(T entity) {
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.