Source stringclasses 1
value | Date int32 2.01k 2.01k | Text stringlengths 3 15.9M | Token_count int32 1 2.44M |
|---|---|---|---|
github-java-corpus | 2,012 |
import java.awt.Graphics;
/**
* A basic line
*
* Defines a basic line class that runs from a starting point to and ending
* point.
*/
public class LineShape extends TwoEndShape {
/**
*
* Draws a simple line from the starting to ending point.
*
* @see tools.shapes.TwoEndShape#draw(java.awt.Graphics... | 229 |
github-java-corpus | 2,012 |
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.Icon;
/**
* Maps tool selection to a specific tool.
*
* Provides tool selection ability for any visual components that utilize
* AbstractAction's. This is especially important as it allows for the... | 429 |
github-java-corpus | 2,012 |
import java.util.Enumeration;
/**
* Provides an iterator for a ToolList.
*
* Iterates over an Enumeration of generic objects for a similar reason that
* the ToolList stores generic Objects. This helps minimize the number of places
* the code needs to be changed in the event a different ToolController class
* i... | 249 |
github-java-corpus | 2,012 |
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
/**
* Draws the background color on the canvas, thus erasing.
*
* Follows the user's mouse movement and erases as the user drags the mouse
* across the DrawingCanvas.
*/
public class EraserTool extends Tool ... | 747 |
github-java-corpus | 2,012 |
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
/**
* Generic parent class for a MiniDraw Tool.
*
* This class is not meant to be instantiated directly, and thus, it is declared
* ... | 315 |
github-java-corpus | 2,012 | import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
* Represents the MiniDraw program and can be initialized as either an
* application or an applet. This contains references to the main
* components of MiniDraw and is responsible for initializing those references
* and any a... | 1,478 |
github-java-corpus | 2,012 | import java.awt.Color;
import java.util.Vector;
public class DrawnObject {
int topLeftX;
int topLeftY;
int bottomRightX;
int bottomRightY;
String creatorTool;
Color color;
boolean filled;
Vector<Object> otherThings;
public int getTopLeftX() {
return topLeftX;
}
public void setTopLeftX(int topLeftX) {
... | 420 |
github-java-corpus | 2,012 |
import java.util.Vector;
/**
* A basic vector list that is intended to contain ToolControllers.
*
* Type checking is performed on object insertion, which forces a slight
* performance penalty on program startup and for every subsequent tool that
* is added to the list. This seems to balance extensibility with ty... | 255 |
github-java-corpus | 2,012 |
import java.awt.Graphics;
/**
* Defines the basic notion of a TwoEndShape.
*
* This class is not meant to be instantiated directly, but rather, should be
* used as a parent class for all TwoEndShapes. The core identity of a
* TwoEndedShape is defined by both the draw and drawOutline methods which are
* explai... | 275 |
github-java-corpus | 2,012 |
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
public class DrawingCanvasController implements MouseListener,
MouseMotionListener,
... | 736 |
github-java-corpus | 2,012 |
import javax.swing.*;
/**
* Provides a Menu-type view displaying the MiniDraw Tools supplied. Menus
* are general hierarchical and display options via text sometimes accompanied
* by icons.
*
*
* Displays the associated buttons tools within the supplied ToolList. The
* ToolList itself contains the various t... | 304 |
github-java-corpus | 2,012 |
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* Panel which provides options for clearing the canvas and selecting the
* current drawing tool.
*/
@SuppressWarnings("seri... | 574 |
github-java-corpus | 2,012 |
import java.awt.Graphics;
/**
* Defines how to draw a Rectangle on the DrawingCanvas
*/
public class RectangleShape extends TwoEndShape {
/* (non-Javadoc)
*
* Defines how to draw the rectangle with corners at the starting and ending
* point. The smallest coordinates of the starting and ending positions ... | 559 |
github-java-corpus | 2,012 |
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.MouseEvent;
/**
* Draws any TwoEndShape on the DrawingCanvas.
*
* This tool takes advantage of some generic behavior for drawing a shape. Any
* TwoEndShape can be drawn with this tool where a TwoEndShape is defined as
... | 1,081 |
github-java-corpus | 2,012 |
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* Controller which is associated with a ControlPanelView. Functions as an
* ActionListener for the Clear Canvas Button and an ItemListener for the... | 679 |
github-java-corpus | 2,012 |
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.util.Vector;
/**
* Draws text on the canvas.
*
* The user selects the starting point with the mouse and then types in the
* desired text. Cur... | 768 |
github-java-corpus | 2,012 |
import java.awt.Graphics;
/**
* Defines the drawing behavior for drawing an oval.
*/
public class OvalShape extends TwoEndShape {
/* (non-Javadoc)
*
* Defines how to draw the oval bounded by the starting and ending points.
* The smallest coordinates of the starting and ending positions are used to
* ... | 554 |
github-java-corpus | 2,012 | import java.awt.Point;
import java.awt.event.MouseEvent;
public class SelectionTool extends Tool {
DrawingCanvas canvas;
protected Point startingMousePosition;
ToolList toolList;
public SelectionTool(DrawingCanvas c, ToolList l) {
if( c != null )
canvas = c;
else
throw new IllegalArgumen... | 1,445 |
github-java-corpus | 2,012 |
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.util.Vector;
import javax.swing.JCo... | 1,387 |
github-java-corpus | 2,012 |
import javax.swing.Action;
import javax.swing.JToolBar;
/**
* Provides a ToolBar-type view displaying the MiniDraw Tools supplied.
* Toolbars generally consist of picture-buttons sometimes accompanied with
* text.
*
* Displays the associated buttons tools within the supplied ToolList. The
* ToolList itself con... | 299 |
github-java-corpus | 2,012 | package static_ex;
public class Chair {
private String color;
private static int numOfChairs = 0;
public static final int MIN_PRICE = 100;
public Chair(){
//Count instances
Chair.numOfChairs++;
}
public Chair(String color){
this();
this.color = color;
}
public static int getNumOfChairs(){
retu... | 89 |
github-java-corpus | 2,012 | package static_ex;
import java.util.Arrays;
import java.util.Collections;
public class ChairFactory {
public void buildChairs(){
for(int i=0;i<100;i++){
new Chair();
}
System.out.println(Chair.getNumOfChairs());
}
public void buildChairs2(){
for(int i=0;i<1000;i++){
new Chair();
}
System.out.pri... | 136 |
github-java-corpus | 2,012 | package misc;
public class Recortion {
public void doSomethig(int i){
if(i>10){
return;
}
doSomethig(i+1);
System.out.println("Doing something: "+i);
}
public static void main(String[] args) {
Recortion r = new Recortion();
r.doSomethig(5);
}
}
| 84 |
github-java-corpus | 2,012 | package inner;
public interface Captain {
public void fly();
}
| 12 |
github-java-corpus | 2,012 | package inner;
public class Airplane {
private boolean canFeedPassangers;
private ServiceCart[] serviceCarts = new ServiceCart[2];
private Captain captain;
private Captain coPilot;
public Airplane() {
serviceCarts[0] = new ServiceCart();
serviceCarts[1] = new ServiceCart();
captain = new Captain(){... | 239 |
github-java-corpus | 2,012 | package inner;
public class TestAirplane {
public static void main(String[] args) {
Airplane airplane = new Airplane();
Airplane.ServiceCart serviceCart1 = airplane.new ServiceCart();
Airplane.ServiceCart serviceCart2 = airplane.new ServiceCart();
serviceCart1.doRound();
airplane.setCanFeedPassan... | 111 |
github-java-corpus | 2,012 | package ex6;
public class Tester {
public void testEx6_3(){
Ex6_3 e = new Ex6_3();
e.usingForLoop();
}
public void testPrintRandom(){
Ex6_3 e = new Ex6_3();
e.printRandom();
}
public static void main(String[] args) {
Tester t = new Tester();
t.testPrintRandom();
}
}
| 94 |
github-java-corpus | 2,012 | package ex6;
public class Ex6_3 {
//Using for loop
public void usingForLoop(){
int random = (int)(Math.random()*1000);
System.out.println("Prining even numbers from 0 to "+random);
for(int i=2;i<random;i+=2){
System.out.println(i);
}
/* Not encouraged
for (int i = 0; i < random; i++) {
if(i%2==0)... | 246 |
github-java-corpus | 2,012 | package ex6;
public class Ex6_5 {
public void subEx1(){
int randomNumber = (int)(Math.random()*1000000)+1;
int numOfDigits = this.countDigits(randomNumber);
System.out.println("Random "+ randomNumber + " has "+numOfDigits+" digits");
}
public void subEx1_2(){
int randomNumber = 0;
int numOfDigits = 0;... | 237 |
github-java-corpus | 2,012 | package interfaces;
public abstract class Bird implements Flyer, Animal {
final public void eat(){
System.out.println("Yummmmm!!!!");
}
public void tackoff(){
System.out.println("flap flap");
}
}
| 50 |
github-java-corpus | 2,012 | package interfaces;
public class Eagle extends Bird implements Animal,Flyer{
public void tackoff() {
System.out.println("Eagle: Tackoff");
}
public void land() {
System.out.println("Eagle: land");
}
public void fly() {
System.out.println("Eagle: fly");
}
public void shit() {
System.out.println("Eagl... | 86 |
github-java-corpus | 2,012 | package interfaces;
public class BirdManager {
public void testFlight(Flyer flyer){
flyer.tackoff();
flyer.fly();
flyer.land();
}
public void testAnimal(Animal animal){
animal.eat();
animal.shit();
if(animal instanceof Dove){
Dove d = (Dove) animal;
d.doNothing();
}
}
public static voi... | 161 |
github-java-corpus | 2,012 | package interfaces;
public interface Animal {
int age = 5;
public void eat();
public void shit();
}
| 22 |
github-java-corpus | 2,012 | package interfaces;
public class Dove extends Bird {
public void land() {
System.out.println("Dove: land");
}
public void fly() {
System.out.println("Dove: fly");
}
public void shit() {
System.out.println("Dove: shit");
}
public void doNothing(){
}
}
| 70 |
github-java-corpus | 2,012 | package interfaces;
public interface Flyer {
public void tackoff();
public void land();
public void fly();
}
| 22 |
github-java-corpus | 2,012 | package Collections;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class TestCollections {
public static void main(String[] args) {
List list = new Ar... | 392 |
github-java-corpus | 2,012 | package exceptions;
public class Instructor {
int students;
public void doLesson () throws Exception{
if(students == 0){
System.out.println("Oh no!!! - throwing Exception");
throw new Exception("Empty classroom");
}
System.out.println("Doing lesson");
}
}
| 62 |
github-java-corpus | 2,012 | package exceptions;
public class Merakezet {
public void sendInstructor(){
Instructor inst = new Instructor();
try {
inst.doLesson();
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println("The problem is:"+e.getMessage());
System.out.println("I'm sorry");
}
}
publi... | 178 |
github-java-corpus | 2,012 | package exceptions;
public class Test {
public static void main(String[] args) {
Merakezet merakezet = new Merakezet();
merakezet.sendInstructor();
try {
merakezet.sendInstructor2();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
merakezet.se... | 120 |
github-java-corpus | 2,012 | package exceptions;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ExFileRead {
public static void main(String[] args) {
try{
FileReader fileReader = new FileReader("c:/adi.txt");
int r = fileReader.read();
}catch(FileNotFoundException f){
f.pr... | 90 |
github-java-corpus | 2,012 | package poly;
public class Tester {
public static void main(String[] args) {
Shape shape = new Shape();
shape.draw();
Circle circle = new Circle();
circle.draw();
Shape myCircle = new Circle();
myCircle.draw();
myCircle.sayHi();
//Will not work: myCircle.getRadius();
//will not work: Circl... | 94 |
github-java-corpus | 2,012 | package poly;
public class Canvas {
//Good polymorphism practice
public void drawShape(Shape shape){
shape.draw();
}
//Bad polymorphism practice
public void print(Squere squere){
squere.draw();
}
public void print(Circle circle){
circle.draw();
}
}
| 70 |
github-java-corpus | 2,012 | package poly;
public class Circle extends Shape {
public void draw(){
System.out.println("Drawing a nice circle");
}
public int getRadius(){
return 10;
}
}
| 39 |
github-java-corpus | 2,012 | package poly;
public class CanvasTester {
//Good
public void testPoly(){
Canvas canvas = new Canvas();
/*
...
*/
Shape shape;
if(System.nanoTime() % 2 == 0){
shape = new Squere();
}else{
shape = new Circle();
}
canvas.drawShape(shape);
}
//Bad
public void testNonPoly(){
Canvas... | 188 |
github-java-corpus | 2,012 | package poly;
public class Shape {
public void draw(){
System.out.println("Can't draw :(");
}
public void sayHi(){
System.out.println("Hi");
}
}
| 40 |
github-java-corpus | 2,012 | package poly;
public class Squere extends Shape {
public void draw() {
System.out.println("Drawing a nice squere");
}
}
| 29 |
github-java-corpus | 2,012 | package casting;
public class Tester {
public void test1() {
Animal a = new Dog();
if (a instanceof Dog) {
Dog temp = (Dog) a;
temp.bark();
}
}
public void test2() {
Animal a = new Dog();
if (a instanceof Dog) {
((Dog) a).bark();
}
}
public void test3() {
Animal a = new Dog();
a = new C... | 301 |
github-java-corpus | 2,012 | package casting;
public class Animal {
}
| 8 |
github-java-corpus | 2,012 | package casting;
public class Dog extends Animal {
public void bark(){
System.out.println("Hav Hav");
}
}
| 25 |
github-java-corpus | 2,012 | package casting;
public class Cat extends Animal {
public void miau(){
System.out.println("Miauuu");
}
}
| 27 |
github-java-corpus | 2,012 | package event_driven;
public class ClickEvent {
private int x,y;
private Object source;
public ClickEvent(int x, int y, Object source) {
super();
this.x = x;
this.y = y;
this.source = source;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public Object getSource() {
retur... | 91 |
github-java-corpus | 2,012 | package event_driven;
public class OtherClickHandler implements ClickHandler{
public void onClick(ClickEvent clickEvent) {
if(clickEvent.getSource() instanceof Button){
Button b = (Button) clickEvent.getSource();
System.out.println(b.getText());
System.out.println(b.getX()*b.getY());
}
}
public void ... | 89 |
github-java-corpus | 2,012 | package event_driven;
public class ButtonTester {
public static void main(String[] args) {
Button button = new Button(100, 300, "Click Me!");
ClickHandler handler = new RegularClickHandler();
button.addClickHandler(handler);
button.addClickHandler(new OtherClickHandler());
button.addClickHandle... | 165 |
github-java-corpus | 2,012 | package event_driven;
public interface ClickHandler {
public void onClick(ClickEvent clickEvent);
public void onDoubleClick(ClickEvent clickEvent);
}
| 32 |
github-java-corpus | 2,012 | package event_driven;
public class RegularClickHandler implements ClickHandler{
public void onClick(ClickEvent clickEvent) {
System.out.println("Handeling Click");
}
public void onDoubleClick(ClickEvent clickEvent) {
System.out.println("Handeling Double-Click");
}
}
| 60 |
github-java-corpus | 2,012 | package event_driven;
public class Button {
private int x,y;
private String text;
ClickHandler[] handlers = new ClickHandler[5];
public Button(int x, int y, String text) {
super();
this.x = x;
this.y = y;
this.text = text;
}
public void addClickHandler(ClickHandler clickHandler){
for (int i = ... | 335 |
github-java-corpus | 2,012 | package wrapper;
import java.util.ArrayList;
public class DemonstratWrappers {
public static void main(String[] args) {
ArrayList array = new ArrayList();
array.add(2); // => array.add(new Integer(2));
array.add(6); // => array.add(new Integer(6));
for (int i = 0; i < array.size(); i++) {
Sys... | 150 |
github-java-corpus | 2,012 | package course;
public class MobileDev extends Group {
public void study(){
System.out.println("Studying how to develop mobile apps");
}
}
| 31 |
github-java-corpus | 2,012 | package course;
public class ClassRoom {
public void active(Group group){
group.study();
}
}
| 21 |
github-java-corpus | 2,012 | package course;
public class DbAdmin extends Group {
public void study(){
System.out.println("Studying how to set up data bases");
}
}
| 32 |
github-java-corpus | 2,012 | package course;
public class School {
public void operate(){
ClassRoom classRoom = new ClassRoom();
Group g1 = new WebDev();
Group g2 = new MobileDev();
Group g3 = new DbAdmin();
System.out.println(g1);
System.out.println(g2);
classRoom.active(g1);
classRoom.active(g2);
classRoom.active... | 119 |
github-java-corpus | 2,012 | package course;
public class WebDev extends Group {
public void study(){
System.out.println("Studying how to develop web apps");
}
public String toString(){
return "A web dev group";
}
}
| 46 |
github-java-corpus | 2,012 | package course;
public class Group {
public void study(){
System.out.println("Study something...");
}
public String toString(){
return "a group";
}
}
| 35 |
github-java-corpus | 2,012 | package ex;
public class Tester {
public static void main(String[] args) {
Ex4 e = new Ex4();
e.printNumbers();
e.printSum();
e.printAvg();
e.printRemainder();
e.printArea();
}
}
| 56 |
github-java-corpus | 2,012 | package ex;
public class FlowControl {
public void testBreak() {
int num = 0;
do {
num = (int) (Math.random() * 100);
if (num == 0) {
System.out.println("Got 0");
break;
}
System.out.println("Will never run if num=45 ::: " + (10000 / num));
} while (num < 90);
System.out.println("-----... | 245 |
github-java-corpus | 2,012 | package ex;
public class ForLoop {
public void printNumbers(){
for(int i=1;i<=1000;i++){
System.out.println(i);
}
}
public static void main(String[] args) {
ForLoop forLoop = new ForLoop();
forLoop.printNumbers();
}
}
| 66 |
github-java-corpus | 2,012 | package ex;
public class SwitchCase {
int dayOfWeek;
public SwitchCase(int dayOfWeek) {
this.dayOfWeek = dayOfWeek;
}
public void testV1(){
System.out.println(dayOfWeek);
if(dayOfWeek == 1){
System.out.println("Sunday");
}else if(dayOfWeek == 2){
System.out.println("Monday");
}else if(dayOfWeek ... | 307 |
github-java-corpus | 2,012 | package ex;
public class WhileLoop {
public WhileLoop(){
int n = 0;
while(n*n<1000000){
System.out.println("n^2 = "+n*n);
n++;
}
}
public static void main(String[] args) {
WhileLoop whileLoop = new WhileLoop();
}
}
| 75 |
github-java-corpus | 2,012 | package ex;
public class Ex4 {
int num1;
int num2;
public Ex4() {
this.num1 = (int)(Math.random()*100)+1;
this.num2 = (int)(Math.random()*100)+1;
}
public void printNumbers(){
System.out.println("Numbers:"+num1+", "+num2);
}
public void printSum(){
int sum = num1 + num2;
System.out.println("sum... | 219 |
github-java-corpus | 2,012 | package ex_8;
public abstract class Square implements Shape{
public int getVolume(int b){
return b*b;
}
}
| 27 |
github-java-corpus | 2,012 | package ex_8;
public interface Shape {
public int getVolume(int base);
}
| 18 |
github-java-corpus | 2,012 | package ex_8;
public class Cube extends Square {
public int getVolume(int base){
int a = super.getVolume(base);
return a*base;
}
}
| 37 |
github-java-corpus | 2,012 | package ex7;
public class Ex7_3 {
public void eliminate(){
int []a = new int[10];
int maxNum = 10;
for (int i = 0; i < a.length; i++) {
a[i] = (int) (Math.random()*maxNum);
System.out.print(a[i]+"\t");
}
System.out.println("");
int counter = 0;
for (int j = 0; j < maxNum; j++) {
for (int i ... | 378 |
github-java-corpus | 2,012 | package arrays;
import java.util.Arrays;
public class MoreArrays {
public void testStringArray(){
String[] names = new String[]{
"Assaf","Moshe","Avi", "Eli"
};
for (int i = 0; i < names.length; i++) {
System.out.println(names[i]);
}
//This will cause an exception
System.out.println(names[4... | 663 |
github-java-corpus | 2,012 | package arrays;
import java.util.Arrays;
public class MoreSorts {
public void sort(int[] a){
Arrays.sort(a);
}
public static void main(String[] args) {
MoreSorts ms = new MoreSorts();
int[] array = new int[]{999,3,6,1,9,5,2,0,8,-55,100,22};
ms.sort(array);
for (int i = 0; i < array.length; i++) {
S... | 124 |
github-java-corpus | 2,012 | package arrays;
public class BubbleSort {
public void sort(int[] a){
int n = a.length;
boolean changed = false;
do{
changed = false;
for (int i = 1; i < n; i++) {
if(a[i-1]>a[i]){
int temp = a[i];
a[i] = a[i-1];
a[i-1] = temp;
changed = true;
}
}
}while(changed);
}
... | 204 |
github-java-corpus | 2,012 | package arrays;
public class HelloArrays {
public void firstEx(){
int[] numbers = new int[10];
for(int i=0;i<10;i++){
numbers[i] = i*2;
}
System.out.println("Done initialization");
for(int i=0;i<10;i++){
System.out.println(numbers[i]);
}
}
public void firstEx2(int numOfNumbers){
int[... | 448 |
github-java-corpus | 2,012 | package ex5;
public class Tester {
public void testEx5_1(){
Ex5_1 ex5_1 = new Ex5_1();
ex5_1.printBigger();
}
public void testEx5_2(){
Ex5_2 ex = new Ex5_2();
}
public static void main(String[] args) {
Tester tester = new Tester();
tester.testEx5_2();
}
}
| 100 |
github-java-corpus | 2,012 | package ex5;
public class Ex5_2 {
private int num = (int)(Math.random()*100);
public Ex5_2(){
System.out.println(num);
if(num>50){
System.out.println("Big !");
}else{
if(num<50){
System.out.println("Small !");
}else{
System.out.println("Bingo !");
}
}
}
}
| 88 |
github-java-corpus | 2,012 | package ex5;
public class Ex5_1 {
private double num1 = Math.random();
private double num2 = Math.random();
public void printBigger(){
System.out.println(num1+" , "+num2);
if(num1>num2){
System.out.println(num1);
}
if(num2>num1){
System.out.println(num2);
}
}
}
| 86 |
github-java-corpus | 2,012 | package ex5;
public class SalaryRaiser {
private int oldSalary = (int)(Math.random()*1001)+5000;
public int raiseSalary1(){
int newSalary = (int)( this.oldSalary * 1.1f);
if(newSalary >= 6000){
newSalary = oldSalary;
}
return newSalary;
}
public int raiseSalary2(){
if(this.oldSalary * 1.1f >= 600... | 201 |
github-java-corpus | 2,012 | package linkedlist;
public class ListManager {
private Book first; //Very important
public void add(Book book){
//Check if is first
if(first == null){
first = book;
return;
}
Book currentBook = first;
while(currentBook.getNextBook()!=null){
currentBook = currentBook.getNextBook();
}
//cur... | 117 |
github-java-corpus | 2,012 | package linkedlist;
public class ListTester {
public static void main(String[] args) {
ListManager listManager = new ListManager();
Book myBook = new Book();
listManager.add(myBook);
listManager.removeLast();
}
}
| 55 |
github-java-corpus | 2,012 | package linkedlist;
public class Book {
private String title;
private String auther;
private int price;
private Book nextBook = null;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getAuther() {
return auther;
}
public void setA... | 152 |
github-java-corpus | 2,012 | package inheritance;
public class Tester {
public static void main(String[] args) {
A a = new A("Hello");
B b = new B();
}
}
| 35 |
github-java-corpus | 2,012 | package inheritance;
public class Circle extends Shape{
private int radius;
public Circle(int radius) {
super("My Shape");
this.radius = radius;
this.area = Math.PI*radius*radius;
System.out.println(super.getArea());
}
public double getArea(){
System.out.println("Getting area");
return getArea();
}... | 74 |
github-java-corpus | 2,012 | package inheritance;
public class B extends A{
public B(){
this("Hello World");
}
public B(String str){
super("From B");
System.out.println("In B:"+str);
}
}
| 48 |
github-java-corpus | 2,012 | package inheritance;
public class Shape {
protected double area;
public Shape(){
System.out.println("Shape created");
}
public Shape(String s){
System.out.println("Shape created :: "+s);
}
public double getArea(){
return area;
}
}
| 55 |
github-java-corpus | 2,012 | package inheritance;
public class Mammel {
protected int legs;
protected int maxAge;
protected int avgWeight;
public Mammel(int legs, int maxAge, int avgWeight) {
super();
this.legs = legs;
this.maxAge = maxAge;
this.avgWeight = avgWeight;
}
public void sayHello(){
}
}
| 79 |
github-java-corpus | 2,012 | package inheritance;
public class A {
public A(String str){
System.out.println(str);
}
public final void print(){
}
}
| 31 |
github-java-corpus | 2,012 | package inheritance;
public class Human extends Mammel{
private int legs;
public Human(){
//Option 1
super(2, 120, 80);
//Option 2
super.legs = 2;
super.avgWeight = 80;
super.maxAge = 120;
//Option 3
this.legs = 2;
this.avgWeight = 80;
this.maxAge = 120;
//Option 4
legs = 3;
avg... | 160 |
github-java-corpus | 2,012 | package abs;
public abstract class Animal {
protected int age;
public abstract void makeSound();
public void actSurprised(){
System.out.println("Ahhhh!!!!");
makeSound();
}
}
| 45 |
github-java-corpus | 2,012 | package abs;
public class Main {
public static void main(String[] args) {
Animal animal = new Snake();
animal.makeSound();
}
}
| 33 |
github-java-corpus | 2,012 | package abs;
public class Snake extends Animal{
public void makeSound() {
System.out.println("ssssssss");
}
}
| 30 |
github-java-corpus | 2,012 | package equals;
public class Tester {
public static void main(String[] args) {
Book b1 = new Book();
b1.setAuthor("Moshe");
b1.setTitle("My great life");
b1.setContent("Once upon a time ...");
b1.setNumOfPages(669);
Book b2 = new Book();
b2.setAuthor("Moshe");
b2.setTitle("My great life");
b2.se... | 158 |
github-java-corpus | 2,012 | package equals;
public class Book {
private String author;
private String title;
private String content;
private int numOfPages;
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getTitle() {
return title;
}
public void setTitle(... | 220 |
github-java-corpus | 2,012 | package tests;
import party.Invitation;
public class TestInvitation {
public static void main(String[] args) {
Invitation invitation = new Invitation("Assaf", "Moshe");
invitation.setLocation("Hanamal");
invitation.setDay(2);
invitation.setMonth(7);
invitation.setYear(2012);
invitation.setFee(250.5F);
... | 120 |
github-java-corpus | 2,012 | package party;
public class Invitation {
private String orginizer;
private String invitee;
private String location;
private float fee;
private int day, month, year;
public Invitation(String orginizer, String invitee){
this.orginizer = orginizer;
this.invitee = invitee;
}
public Invitation(String orgin... | 453 |
github-java-corpus | 2,012 | package pets.hairy;
public class Mouse {
private String name = "Mickey";
public Mouse(String name){
this.name = name;
}
public String getName() {
return name;
}
public void suicide(){
Cat killer = new Cat();
killer.eatMouse(this);
}
}
| 66 |
github-java-corpus | 2,012 | package pets.hairy;
public class Dog {
}
| 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.