I wrote a program for one of my Object Oriented Programming in Java classes(Program 2) and I got docked off because my method was too long, which I'm not complaining about, but.
I got the note: Modularize"Modularize more, method too long SO:."
I was wondering what any of you more experienced programmers would do to simplify/shorten my code for future sake so that I learn how to shorten this sort of code. Thank you so much for consideration:
public void run() throws java.io.IOException
{
stdin = new Scanner(System.in);
String input;
String fraction;
int numPerLine;
boolean inList = false;
input = stdin.next(); // Get the read
while(!input.equalsIgnoreCase("Q"))
{
if(input.equalsIgnoreCase("A"))
{
fraction = stdin.next(); // Get the fraction read
thisFract = new Fraction(fraction);
list.add(thisFract);
System.out.println(thisFract.toString() + " was added "
+ "to the list.");
}
else if (input.equalsIgnoreCase("D"))
{
fraction = stdin.next();
thisFract = new Fraction(fraction);
inList = list.delete(thisFract);
if(inList == true)
System.out.println(thisFract.toString() + " was removed "
+ "from the list.");
else
System.out.println(thisFract.toString() + " is not in the"
+ " list.");
}
else if(input.equalsIgnoreCase("S"))
{
System.out.println("The sum of the list is: " + list.sum());
}