Hi, I’m new to Codecademy and just new to programming in general. I have never posted on a forum like this before either!
I’m completely noob at this. But… I’m thoroughly enjoying my self taught journey to becoming, hopefully one day, a fully fledged Software Developer. I wanted to share my embarrassing attempt for the DNA Sequencing, String Methods, Java exercise. Now, I know this attempt is pathetic and the code is so repetitive and completely not the correct way to do it. But… I was so proud the fact that I managed to do it completely without looking at the guide… from scratch.
Check out my attempt below and please do have a laugh Im also to looking to make some new friends on this, perhaps those who are similar to me in experience and we can learn together? Do hit me up!
Also: any feedback, advises, recommendations would be welcomed !
public class DNA {
public static boolean first3(String dNa) {
dNa.equals("ATG");
return true;
}
public static boolean last3(String dNa) {
dNa.equals("TGA");
return true;
}
public static boolean checkSize(String dNa) {
int size = dNa.length();
if (size % 3 == 0) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
String sample1 = "ATGCGATACGCTTGA";
String sample2 = "ATGCGATACGTGA";
String sample3 = "ATGCGATACGTGA";
boolean condition1 = first3(sample1);
boolean condition2 = last3(sample1);
boolean condition3 = checkSize(sample1);
if (condition1 && condition2 && condition3) {
System.out.println(sample1 + " is a protien");
} else {
System.out.println(sample1 + " is not a protien");
}
boolean condition4 = first3(sample2);
boolean condition5 = last3(sample2);
boolean condition6 = checkSize(sample2);
if (condition4 && condition5 && condition6) {
System.out.println(sample2 + " is a protien");
} else {
System.out.println(sample2 + " is not a protien");
}
}
}
//has to start with ATG
//has to end with TGA
//length must be divisible by 3
//print "is a Protein"
//else print "is not a Protein"
//Sample 1: ATGCGATACGCTTGA
//Sample 2: ATGCGATACGTGA
//Sample 3: ATGCGATACGTGA
.