-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First day problems #1
base: master
Are you sure you want to change the base?
Conversation
String line = br.readLine(); | ||
while ( line != null) { | ||
try { | ||
double numar = Double.parseDouble(line); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice.
|
||
} catch (NullPointerException ignored) { | ||
} | ||
Collator.getInstance().compare("ceva", "altceva"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be removed I think
try { | ||
br = new BufferedReader(new FileReader("src/fisier.txt")); | ||
text = br.readLine(); | ||
String name[] = text.split(","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename the array to 'names' - not critical here, but naming is important!
|
||
} | ||
|
||
public static boolean numeIdeal(String name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this function should be called 'isIdealName' - in real projects all naming will be english, and it is good practice to start boolean functions' names with the appropriate verbs ('is', 'are', 'has' etc.). So at least it would be 'esteNumeIdeal'.
if (!ok) | ||
return false; | ||
|
||
return true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or simply - return ok;
😋
for (int i = 1; i < chars.length; i++) { | ||
if (!Character.isLowerCase(chars[i])) | ||
ok = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good - also think about a solution using RegEx
http://www.vogella.com/tutorials/JavaRegularExpressions/article.html
BufferedReader br = null; | ||
String text = null; | ||
try { | ||
br = new BufferedReader(new FileReader("src/fisier.txt")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the third time that we are using this code for reading from files - how about extracting it into a separate class!
br = new BufferedReader(new FileReader("src/fisier.txt")); | ||
text = br.readLine(); | ||
String name[] = text.split(","); | ||
List<String> nume = Arrays.asList(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
english!
text = br.readLine(); | ||
String name[] = text.split(","); | ||
List<String> nume = Arrays.asList(name); | ||
nume.sort(String::compareToIgnoreCase); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice
try { | ||
br = new BufferedReader(new FileReader("src/fisier.txt")); | ||
text = br.readLine(); | ||
String name[] = text.split(","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array should be called 'names' - although maybe a better alternative would be 'words' or even 'strings', as we are not necessarily reading names from the file. Naming is very important - it determines what other devs will think your intentions are.
} | ||
|
||
public static boolean isVowel(char c) { | ||
return "AEIOUaeiou".indexOf(c) != -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not bad
tricou.setDescription(sc.next()); | ||
tricou.setColor(sc.next()); | ||
tricou.setSize(sc.next()); | ||
System.out.println(tricou); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to always keep the code properly indented and formatted - use CTRL+ALT+L in IDEA to auto-arrange it quickly at any time!
} | ||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try to avoid having extra newlines where they do not improve code readability - in real projects this would actually reduce readability
Problema asta am facut-o in timpul cursului trecut si o terminasem, nu am mai facut-o inca odata acasa si am luat main-ul direct din calculator fara sa ma mai uit ce e in el On Monday, November 27, 2017, 8:52:08 PM GMT+2, Paul Hristea <[email protected]> wrote:
@paulhristea commented on this pull request.
In Main/Java/com/codegile/university/razvan/week1/day1/Problem1/Main.java:
+ BufferedReader br = new BufferedReader(in);
+ int count1=0, count2=0;
+ try {
+ String line = br.readLine();
+ while ( line != null) {
+ try {
+ double numar = Double.parseDouble(line);
+ if (numar % 1 == 0)
+ count1++;
+ else
+ count2++;
+ line = br.readLine();
+
+ } catch (NullPointerException ignored) {
+ }
+ Collator.getInstance().compare("ceva", "altceva");
is this used for anything?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
no problem! Eu comentez pe cele mai mici chestii pentru că deocamdată acesta este tot codebase-ul pe care putem discuta. Cel mai util ar fi dacă din comentarii din astea reușim să pornim discuții constructive |
No description provided.