Skip to content

Instantly share code, notes, and snippets.

@damithc
Last active January 31, 2020 05:41
Show Gist options
  • Save damithc/c27161d3472ca2e2fe0fba923c81fc77 to your computer and use it in GitHub Desktop.
Save damithc/c27161d3472ca2e2fe0fba923c81fc77 to your computer and use it in GitHub Desktop.
CS2113-M16: Tutorial 3, task 5
import java.util.*;
public class Manage_Task {
private String description;
private boolean important;
private int i; // used to count tasks
String pastDescription[] = new String[10]; // a list of past descriptions
public Manage_Task(String d) {
this.description = d;
if (!d.isEmpty())
// set as important
this.important = true;
}
public String getAsXML() { return "<task>"+description+"</task>"; }
public void printingDescription(){ System.out.println(this); }
public String toString() { return description; }
}
@tqiren
Copy link

tqiren commented Jan 30, 2020

Line 5: private boolean important should be changed to isImportant, to indicate boolean variables as a question for better readability.

@yantingsanity
Copy link

Line 3: The naming of a class should be in PascalCase format and a noun as a form of good coding naming standard. The name of the class could be changed to TaskManager instead of Manage_Task.

@JensonWee
Copy link

Line 10, 11, 13: Basic indentation should be 4 spaces instead of 2.

@zi-hui
Copy link

zi-hui commented Jan 30, 2020

Lines 3,9 Manage_Task should be renamed as Class/enum names must be nouns and written in PascalCase.
Line 5, private boolean important, important should be changed to isImportant as Boolean variables/methods should be named to sound like booleans

@Keith-JK
Copy link

Keith-JK commented Jan 31, 2020

Comments should be indented relative to their position in the code.

Method definitions should have the following form:

public void someMethod() throws SomeException {
...
}

@cheongisabella
Copy link

Line 7: It should be String[] pastDescriptions instead of String pastDescription[]. Array specifiers must be attached to the type not the variable, and it should be plural form as stated by one of the comments above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment