Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions achyut/src/main/java/com/lftechnology/one/DefaultTest.java

This file was deleted.

10 changes: 0 additions & 10 deletions achyut/src/main/java/com/lftechnology/one/Main.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.lftechnology.programs;

import java.util.Scanner;

public class MultiplierProgram {

private int numberOfMultiple;
private int firstMultiplier;
private int secondMultiplier;
private Scanner scanner;

public MultiplierProgram() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule


}

public void run() {
this.initiateRun();
System.out.println("->Please Enter the Number of Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

scanner = new Scanner(System.in);
this.numberOfMultiple = scanner.nextInt();
System.out.println("->Please Enter First Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

this.firstMultiplier = scanner.nextInt();
System.out.println("->Please Enter Second Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

this.secondMultiplier = scanner.nextInt();
int sum = calculateMultiplier();
System.out.println("Sum of multiple by " + this.firstMultiplier + " and " + this.secondMultiplier + " below "
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

+ this.numberOfMultiple + "=" + sum);
this.endRun();
}

public int calculateMultiplier() {

int sum = 0;
for (int i = 0; i < this.numberOfMultiple; i++) {
if ((i % this.firstMultiplier) == 0 || (i % this.secondMultiplier) == 0) {
sum += i;
}
}
return sum;
}

public void initiateRun() {
System.out.println("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("->Executing Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule


}

public void endRun() {
System.out.println("-----------------------------------------");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("-----------------------------------------\n\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.lftechnology.programs;

import java.util.Scanner;

public class PalindromeProgram {

private String number;
private Scanner scanner;

public PalindromeProgram() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule


}

public void run() {
this.initiateRun();
System.out.println("->Please Enter the Number of Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

scanner = new Scanner(System.in);
this.number = scanner.nextLine();
Boolean isPalindrome = this.isPalindrome();
if (isPalindrome == true) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove the literal "true" boolean value. rule

System.out.println("The number is a palindrome number");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

} else {
System.out.println("The number is not a palindrome number");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}
this.endRun();
}

public Boolean isPalindrome() {
String reverse = "";
int length = this.number.length();
for (int i = length - 1; i >= 0; i--)
reverse = reverse + this.number.charAt(i);

if (this.number.equals(reverse))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Replace this if-then-else statement by a single return statement. rule

return true;
else
return false;

}

public void initiateRun() {
System.out.println("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("->Executing Palindrome Program");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule


}

public void endRun() {
System.out.println("-----------------------------------------");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("-----------------------------------------\n\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.lftechnology.programs;

import java.util.Scanner;

public class SalutationProgram {

private Scanner fullNameWithSalutationInput;
private String fullNameWithSalutation;
private String salutation;

public SalutationProgram() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule


}

public void run() {
this.initiateRun();
this.askForInput();
if (this.fullNameWithSalutation.length() <= 0) {
System.out.println("->Input can't be empty! Enter again");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

this.askForInput();
}
this.splitInput();
System.out.println("Salutation = " + this.salutation);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("FullName = " + this.fullNameWithSalutation);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

this.endRun();
}

public void initiateRun() {
System.out.println("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("->Executing Salutation");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("->Please Enter Your Full Name with Salutation (e.g, Mr. John Doe)\n\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}

public void endRun() {
System.out.println("-----------------------------------------");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("-----------------------------------------\n\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

}

public void splitInput() {
String[] splited = this.fullNameWithSalutation.split("\\s+");
this.salutation = splited[1];
}

public void askForInput() {
fullNameWithSalutationInput = new Scanner(System.in);
this.fullNameWithSalutation = fullNameWithSalutationInput.nextLine();
}

}
25 changes: 25 additions & 0 deletions achyut/src/main/java/com/lftechnology/runner/Executer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.lftechnology.runner;

import java.util.Scanner;

public class Executer {

private static Scanner userInput;
public static int chosenOption;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL Make this "public static chosenOption" field final rule
MAJOR Make chosenOption a static final constant or non-public and provide accessors if needed. rule


public static void main(String[] args) {
Menu menu = new Menu();
menu.showmenu();
}

public void askForInputAndRun() {
/**
* @todo Check if user input is empty in all the subsequent classes
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO Complete the task associated to this TODO comment. rule

*/
userInput = new Scanner(System.in);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL Make the enclosing method "static" or remove this set. rule

Executer.chosenOption = userInput.nextInt();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CRITICAL Make the enclosing method "static" or remove this set. rule

TaskSwitcher taskSwitcher = new TaskSwitcher(Executer.chosenOption);
taskSwitcher.switchAndRun();
}

}
22 changes: 22 additions & 0 deletions achyut/src/main/java/com/lftechnology/runner/Menu.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.lftechnology.runner;

public class Menu {

public Menu() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. rule


}

public void showmenu() {
System.out.println("->Please hit the options below to play with us");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("Options Program");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("1 Salutation");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("2 Multiplier");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("3 Palindrome");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("0 Exit");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("......................");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.print("->Press the option above to continue: ");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

Executer executor = new Executer();
executor.askForInputAndRun();
}

}
41 changes: 41 additions & 0 deletions achyut/src/main/java/com/lftechnology/runner/TaskSwitcher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.lftechnology.runner;

import com.lftechnology.programs.MultiplierProgram;
import com.lftechnology.programs.PalindromeProgram;
import com.lftechnology.programs.SalutationProgram;

public class TaskSwitcher {

protected int chosenOption;

public TaskSwitcher(int option) {
this.chosenOption = option;
}

public void switchAndRun() {
Menu menu = new Menu();
switch (this.chosenOption) {
case 1:
SalutationProgram salutationProgram = new SalutationProgram();
salutationProgram.run();
break;
case 2:
MultiplierProgram multiplierProgram = new MultiplierProgram();
multiplierProgram.run();
break;
case 3:
PalindromeProgram palindromeProgram = new PalindromeProgram();
palindromeProgram.run();
break;
case 0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR End this switch case with an unconditional break, return or throw statement. rule

System.out.println("->You are exiting the program now...");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("->Exited");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.exit(0);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Remove this call to "exit" or ensure it is really required. rule

default:
System.out.println("->Invalid Input");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

System.out.println("\n");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MAJOR Replace this usage of System.out or System.err by a logger. rule

menu.showmenu();
}
menu.showmenu();
}
}
12 changes: 0 additions & 12 deletions achyut/src/main/java/com/lftechnology/two/PackageTwoMain.java

This file was deleted.