id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
190b7801-ff38-40b2-8b50-bc509cb9e78b | public static void main(String[] args) {
System.getProperties().list(System.out);
Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost:3306/Webber_DB?zeroDateTimeBehavior=convertToNull","root","852456diego852456");
createEmployee();
logger.info("=========> Created employee:");
selectEmployee();
updateEmployee();
logger.info("=========> Updated employee:");
selectAllEmployees();
deleteEmployee();
logger.info("=========> Deleted employee:");
selectAllEmployees();
createEmployee();
logger.info("=========> Created employee:");
selectEmployee();
deleteAllEmployees();
logger.info("=========> Deleted all employees:");
selectAllEmployees();
Base.close();
} |
040ca5a1-2988-455b-8593-5f807c67c9e7 | private static void createEmployee() {
Employee e = new Employee();
e.set("first_name", "John");
e.set("last_name", "Doe");
e.saveIt();
} |
503ade51-d512-437d-aac2-cb15cf088258 | private static void selectEmployee() {
Employee e = Employee.findFirst("first_name = ?", "John");
logger.info(e.toString());
} |
3f672284-538f-4460-923d-763482148ba3 | private static void updateEmployee() {
Employee e = Employee.findFirst("first_name = ?", "John");
e.set("last_name", "Steinbeck").saveIt();
} |
8abd5061-3747-47d7-bb93-a36ab2a045f2 | private static void deleteEmployee() {
Employee e = Employee.findFirst("first_name = ?", "John");
e.delete();
} |
de207e38-8012-4256-a4b0-db92903ae96a | private static void deleteAllEmployees() {
Employee.deleteAll();
} |
5ba249c1-4e56-4476-99ce-b40cc5ce5273 | private static void selectAllEmployees() {
logger.info("Employees list: " + Employee.findAll());
} |
cb584de2-10c7-416e-b451-1ded9a8fddbd | @Before
public void before(){
Base.open("com.mysql.jdbc.Driver", "jdbc:mysql://localhost/test", "root", "p@ssw0rd");
Base.openTransaction();
} |
a91166fd-e538-4f0c-92f7-3c0b30fe3444 | @After
public void after(){
Base.rollbackTransaction();
Base.close();
} |
ac596e1e-d94d-4c56-a87c-c1bf6db0e4c9 | @Test
public void shouldValidateMandatoryFields(){
Employee employee = new Employee();
//check errors
the(employee).shouldNotBe("valid");
the(employee.errors().get("first_name")).shouldBeEqual("value is missing");
the(employee.errors().get("last_name")).shouldBeEqual("value is missing");
//set missing values
employee.set("first_name", "John", "last_name", "Doe");
//all is good:
the(employee).shouldBe("valid");
} |
014e7e62-e826-4a82-8222-f2a35c51dc6e | public static void main(String[] args) {
boolean exit = false;
Input in = new Input();
CircularShift cs = new CircularShift();
Alphabetizer ab = new Alphabetizer();
Output out = new Output();
Pipe p1 = new Pipe();
Pipe p2 = new Pipe();
Pipe p3 = new Pipe();
//register filters and pipes
in.register(p1);
p1.register(cs);
cs.register(p2);
p2.register(ab);
ab.register(p3);
p3.register(out);
//read the screen input as the dataIn for Input filter
System.out.println("Enter the titles here:");
ArrayList<String> inputData = new ArrayList<String>();
while (!exit) {
Scanner input = new Scanner(System.in);
String line = input.nextLine();
if (line.equals("esc"))
break;
inputData.add(line);
in.getData(inputData);
}
} |
0b4a147b-8fff-4fb5-8a0f-0b5ae8e542ec | public void register(Filter next) {
this.next = next;
} |
6f846191-7583-4ea6-afef-ca981b57cec0 | public void dataIn(ArrayList<String> d) {
next.getData(d);
} |
5c55bb29-b7bf-4137-a284-7e9f655e9b63 | @Override
public void processData() {
// TODO Auto-generated method stub
_processedData.clear();
for (int i=0;i<_data.size();i++){
_processedData.addAll(circularShift(_data.get(i)));
}
} |
8fa9df57-1197-4ec7-a03a-14e7b44ebc4c | private ArrayList<String> circularShift(String line) {
String[] wordList = line.trim().split(" ");
int wordCount = wordList.length;
ArrayList<String> shiftedList = new ArrayList<String>();
if (wordCount < 2){
String firstWord = line.trim();
if (IGNORE_LIST.contains(firstWord.toLowerCase())||firstWord.isEmpty()) return shiftedList;
else {
shiftedList.add(line.toUpperCase());
return shiftedList;
}
}
for (int i = 0; i < wordCount; i++) {
String firstWord = line.split(" ", 2)[0];
String restWords = line.split(" ", 2)[1].trim();
StringBuffer shiftedLine = new StringBuffer();
StringBuffer newLine = new StringBuffer();
// If the first word is to be ignored, jump to next shift
if (IGNORE_LIST.contains(firstWord.toLowerCase())) {
newLine.append(restWords);
newLine.append(" ");
newLine.append(firstWord);
line = newLine.toString();
continue;
} else {
shiftedLine.append(firstWord.toUpperCase());
shiftedLine.append(" ");
shiftedLine.append(restWords);
shiftedList.add(shiftedLine.toString());
newLine.append(restWords);
newLine.append(" ");
newLine.append(firstWord);
line = newLine.toString();
}
}
return shiftedList;
} |
06941ecb-e86a-476c-adc2-7e4faaa77275 | @Override
public void processData() {
// TODO Auto-generated method stub
_processedData = _data;
} |
5d48ccb6-817d-46f3-8717-0431f657c271 | @Override
public void processData() {
// TODO Auto-generated method stub
_processedData = sortLines(_data);
} |
80810089-170c-4524-94d2-79d65e5e1cb7 | public ArrayList<String> sortLines(ArrayList<String> lines) {
Collections.sort(lines);
return lines;
} |
227ef659-6cee-4352-9446-8262ff0381ed | abstract public void processData(); |
e35e505e-a432-4ced-a434-fa0cb58cd64b | public void register (Pipe out) {
if (_dataOUTPipe == null)
_dataOUTPipe = out;
} |
6ad1fe4b-e310-47e7-8a4d-02f5ef8f626a | public void sendData () {
if (_processedData!=null)
_dataOUTPipe.dataIn(_processedData);
} |
f41ab7c2-142d-40c9-b308-1b72e9fbe6ec | public void getData(ArrayList<String> d) {
_data = d;
processData();
sendData();
} |
a8548b56-d0ed-4bdc-ac4d-04610144b3f7 | @Override
public void processData() {
// TODO Auto-generated method stub
displayLines(_data);
_processedData = null;
} |
e4c6cd02-ec16-45a5-a9a0-f3ecfc9d02de | private void displayLines(ArrayList<String> lines) {
for (int i = 0; i < lines.size(); i++) {
System.out.printf(lines.get(i)+"\n");
}
} |
31f7712b-363c-4072-89ec-eab80367374d | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission){
super(fname, lname, salary);
this.comissionRate = comission;
this.totalSales = 0;
} |
4f4dadc2-21d5-4bee-b012-772078cffcc2 | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission, double sales){
super(fname, lname, salary);
this.comissionRate = comission;
this.totalSales = sales;
} |
1642f755-1b3f-4e20-aa0e-4a4f97727dc5 | public double getComissionRate() {
return comissionRate;
} |
948de475-876a-4ea4-9d8c-06c6dd922f9f | public void setComissionRate(double comissionRate) {
this.comissionRate = comissionRate;
} |
8ba500b6-6fd3-4d3d-98bc-563048b7423f | public double getTotalSales() {
return totalSales;
} |
456c0f86-d09f-45ba-a828-8b6a48e8806e | public void setTotalSales(double totalSales) {
this.totalSales = totalSales;
} |
72525582-8ce8-4d72-b4a0-1cf01f4772a0 | public void addSales(double sales){
this.totalSales += sales;
} |
28a7c3e3-a035-42dd-b094-d3d536572dd1 | public double getComissionEarned(){
return this.totalSales * this.comissionRate;
} |
96b61861-b0dd-4b4b-98ff-35604c07ed62 | @Override
public double getYearlyPay(){
return (super.getYearlyPay() * (this.totalSales * this.comissionRate));
} |
1410ba4d-9a3a-457e-a97b-ae4d21df9460 | @Override
public String toString(){
return super.toString() + "\rComission rate: " + this.comissionRate + "\rTotal sales made: $" + this.totalSales + "\rComission earned: $" + this.getComissionEarned() + "\rTotal salary with comission: $" + this.getYearlyPay();
} |
e14b4bb7-11ae-461d-864d-2360444623bc | public String getFirstName() {
return firstName;
} |
330ee1e2-712c-42af-96db-984471d13b52 | public void setFirstName(String firstName) {
this.firstName = firstName;
} |
a1a880f1-a52c-46d7-99d0-95b8d2df1ce6 | public String getLastName() {
return lastName;
} |
9e2e7ac5-e626-41d4-9752-19961c396897 | public void setLastName(String lastName) {
this.lastName = lastName;
} |
80bb3703-3c8b-4825-9141-82a0eb798a57 | public int getEmpID() {
return empID;
} |
b8d0393e-4d79-4894-8f6e-fa35fc6e5d8a | public abstract double getYearlyPay(); |
a778d5a1-6561-42f8-8665-acd85e3b25c6 | public abstract String toString(); |
5915ac9d-d201-433e-94ae-a27d862c91f0 | public SalariedEmployee(String fname, String lname, double salary){
super.setFirstName(fname);
super.setLastName(lname);
this.salary = salary;
} |
ea38484d-b3fb-443f-a1db-67cef5defbae | @Override
public double getYearlyPay(){
return this.salary;
} |
5c25ccfd-5a7d-4b1a-b18f-e412fdb9136b | public void setSalary(double salary) {
this.salary = salary;
} |
14201a37-5641-49a5-a5ab-c9fbb6339917 | @Override
public String toString(){
return "Employee ID: "+ super.getEmpID() + "\rEmployee name: " + super.getLastName() + ", " + super.getFirstName() + "\rAnnual salary: $" + this.salary;
} |
d6aacda2-8e70-464b-a774-ad307b3dfd24 | public HourlyEmployee(String fname, String lname, double pay, double hours){
super.setFirstName(fname);
super.setLastName(lname);
this.hourlyRate = pay;
this.weeklyHours = hours;
} |
847f1125-6822-4248-a230-cd20a199b0e2 | public double getHour_rate() {
return hourlyRate;
} |
e361804b-3681-4772-9604-90964ec85c0e | public void setHour_rate(double hourlyRate) {
this.hourlyRate = hourlyRate;
} |
6e455173-e7cf-498e-840d-881539747c38 | public double getWeeklyHours() {
return weeklyHours;
} |
da131846-33cb-4be3-870b-816c9f591160 | public void setWeeklyHours(double weeklyHours) {
this.weeklyHours = weeklyHours;
} |
62e56b0b-26b1-472e-93a7-7bffa1c2fff0 | public double getWeeklyWage(){
return hourlyRate * weeklyHours;
} |
fb552446-a3f7-46cc-a2b8-8073da84f218 | @Override
public double getYearlyPay(){
return (this.getWeeklyWage() * 52);
} |
2179050d-8a7a-4ea9-b7af-d64a50930e80 | @Override
public String toString(){
return "Employee ID: "+ super.getEmpID() + "\rEmployee name: " + super.getLastName() + ", " + super.getFirstName() + "\rHourly rate: " + this.hourlyRate + "\rHours per week: " + this.weeklyHours;
} |
6e45029b-2d77-4b46-9973-e0612df784fa | public static void main(String[] args){
} |
0cd9a30f-e4c4-4140-b334-d26dbb81c5e2 | public static void main(String[] args) {
// TODO code application logic here
} |
a1e3f6a3-e2b7-44a3-801b-b89ca1f69de9 | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission){
super(fname, lname, salary);
this.comissionRate = (comission/100);
this.totalSales = 0;
} |
72c2b8e7-5a63-450a-ac51-f07f45e387f8 | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission, double sales){
super(fname, lname, salary);
this.comissionRate = (comission/100);
this.totalSales = sales;
} |
8553d5b3-470b-4b91-992b-65c8dadc7b68 | public double getComissionRate() {
return comissionRate;
} |
9c15d5b7-a4cb-415b-b9e8-5e403f6df197 | public void setComissionRate(double comissionRate) {
this.comissionRate = comissionRate;
} |
b88164f1-934f-467b-b3bd-ef78f3a5e9ec | public double getTotalSales() {
return totalSales;
} |
11b36a6b-8eff-49f4-8a24-2c369fc5de34 | public void setTotalSales(double totalSales) {
this.totalSales = totalSales;
} |
ef7639fb-fa3f-4a39-b16f-d10f5bb29754 | public double getComissionEarned(){
return this.totalSales * this.comissionRate;
} |
303de90a-77fd-49ed-9aee-a0b4a4da58f6 | public double getTotalSalary(){
return super.getSalary() + (this.totalSales * this.comissionRate);
} |
6029a02f-63ed-4f76-a82f-a8e9f74d4e6a | @Override
public String toString(){
return super.toString() + "\rComission rate: " + this.comissionRate + "\rTotal sales made: $" + this.totalSales + "\rComission earned: $" + this.getComissionEarned() + "\rTotal salary with comission: $" + this.getTotalSalary();
} |
fc7446cb-77f9-47c6-b62c-e1a56b899ef9 | public Employee(String fname, String lname){
this.firstName = fname;
this.lastName = lname;
this.empID = empNo++;
} |
26cb8ae4-6479-47b2-b1aa-ad92906f7986 | public String getFirstName() {
return firstName;
} |
819a7a31-2b7f-4989-9d3d-9a7191aa9441 | public void setFirstName(String firstName) {
this.firstName = firstName;
} |
bf6e6ffe-8c0c-4edc-b573-d7edfe3f9795 | public String getLastName() {
return lastName;
} |
e1d188a2-db6b-4d00-9152-16622b8ad4d2 | public void setLastName(String lastName) {
this.lastName = lastName;
} |
eb0b81c7-5264-48df-99d7-3cd953f9357c | public int getEmpID() {
return empID;
} |
a8fd5c31-721d-4041-998c-0d67483b8088 | @Override
public String toString(){
return "Employee ID: "+ this.empID + "\rEmployee name: " + this.lastName + ", " + this.firstName;
} |
82194721-b632-4b1e-a089-7a25e38645ee | public SalariedEmployee(String fname, String lname, double salary){
super(fname, lname);
this.salary = salary;
} |
eddb23ca-7d03-4748-99f5-7b992ada93ab | public double getSalary() {
return salary;
} |
9cd75ae0-60b1-4b1b-bdc5-d6fb6291dfc1 | public void setSalary(double salary) {
this.salary = salary;
} |
296c6994-240d-4519-b128-4df67985f4af | @Override
public String toString(){
return super.toString() + "\rAnnual salary: $" + this.salary;
} |
a831dfe9-1782-43c4-be20-9df592e7c3ca | public static void main(String[] args) {
// TODO code application logic here
Employee e1 = new Employee("John", "Doe");
System.out.println(e1.toString());
e1.setFirstName("Steve");
e1.setLastName("Johnson");
System.out.println(e1.toString());
Employee e2 = new Employee("Ron", "McDonald");
System.out.println(e2.toString());
Employee e3 = new HourlyEmployee("Steve", "Erwin", 7.75, 15);
System.out.println(e3.toString());
//System.out.println(e3.getWeeklyWage()); Doesn't compile
HourlyEmployee e4 = (HourlyEmployee)e3;
System.out.println(e4.toString());
System.out.println(e4.getWeeklyWage());
SalariedEmployee e5 = new SalariedEmployee("Charles", "Darwin", 80000);
System.out.println(e5.toString());
SalaryPlusComissionEmployee e6 = new SalaryPlusComissionEmployee("Bruce", "Wayne", 100000, 30);
System.out.println(e6.toString());
e6.setTotalSales(120000);
System.out.println(e6.toString());
} |
0fea4174-553c-4518-af1e-6bae17a4623f | public HourlyEmployee(String fname, String lname, double pay, double hours){
super(fname, lname);
this.hourlyRate = pay;
this.weeklyHours = hours;
} |
8b7e5eaa-bb51-4cdb-a51b-2b5aa867dc02 | public double getHour_rate() {
return hourlyRate;
} |
1c71ba5f-bef9-44ed-ad0e-8fb5318116e8 | public void setHour_rate(double hourlyRate) {
this.hourlyRate = hourlyRate;
} |
73ea679a-4883-4002-aeda-e67aa3130eb5 | public double getWeeklyHours() {
return weeklyHours;
} |
511beb62-768e-4fcf-a01f-e894cce00ed1 | public void setWeeklyHours(double weeklyHours) {
this.weeklyHours = weeklyHours;
} |
691ca946-692c-4730-9e10-c7e9af228b99 | public double getWeeklyWage(){
return hourlyRate * weeklyHours;
} |
9ac86665-9dbe-4e98-a2ba-5fb978918a24 | @Override
public String toString(){
return super.toString() + "\rHourly rate: " + this.hourlyRate + "\rHours per week: " + this.weeklyHours;
} |
2be532cb-2bc9-4bc4-a553-7da6ab247be5 | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission, int empID){
super(fname, lname, salary, empID);
this.comissionRate = (comission/100);
this.totalSales = 0;
} |
908aefe1-46d4-4ac9-824a-c9ec3cb35570 | public SalaryPlusComissionEmployee(String fname, String lname, double salary, double comission, int empID, double sales){
super(fname, lname, salary, empID);
this.comissionRate = (comission/100);
this.totalSales = sales;
} |
8ce7f78d-c9ef-42d4-a504-69d1154d8efc | public double getComissionRate() {
return comissionRate;
} |
5fae4c9b-9aa2-4deb-80f4-211364256355 | public void setComissionRate(double comissionRate) {
this.comissionRate = comissionRate;
} |
bd057bcc-57ad-4a6b-9243-1e7b66aa159b | public double getTotalSales() {
return totalSales;
} |
480f26af-bcb5-49ef-adcf-d883cb1252ba | public void setTotalSales(double totalSales) {
this.totalSales = totalSales;
} |
a0efbc5f-51de-433d-9531-2ca8d372e0b3 | public double getComissionEarned(){
return this.totalSales * this.comissionRate;
} |
fa72606e-1c01-4e6a-916d-204308d4308f | public double getTotalSalary(){
return super.getYearlyPay() + (this.totalSales * this.comissionRate);
} |
3bfdb7ab-8f08-4060-aa15-15a88a46419d | @Override
public String toString(){
return super.toString() + "\rComission rate: " + this.comissionRate + "\rTotal sales made: $" + this.totalSales + "\rComission earned: $" + this.getComissionEarned() + "\rTotal salary with comission: $" + this.getTotalSalary();
} |
0c08e32a-d13b-46fa-98b9-98bbd70d3f7c | public String getFirstName(); |
700189f6-22d5-4c09-8a12-6c7764aa7134 | public void setFirstName(String firstName); |
bc6c12c0-c6d8-40f9-b37f-bc6a1d848b2a | public String getLastName(); |
e1df3210-2ef0-48c6-a25f-536341a40f6b | public void setLastName(String lastName); |
1ab53569-2e86-4060-bca8-74b9c97a5881 | public void setEmpID(int empID); |
5d2a4d9f-704f-4577-9479-7991250e87a7 | public int getEmpID(); |
a5de20dc-1254-4bf8-8aae-46ab999ec966 | public double getYearlyPay(); |
514f3a54-e2db-4d27-a3ff-0d438a1c22be | public String toString(); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.