Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public class HelloMethods {

public static void main(String[] args) {
String message = Message.getMessage("fr");
String message = Message.getMessage("de");
System.out.println(message);
}

Expand Down
2 changes: 2 additions & 0 deletions src/org/launchcode/java/demos/lsn1datatypes/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public static String getMessage(String lang) {
return "¡Hola, Mundo!";
} else if (lang.equals("fr")) {
return "Bonjour, le monde!";
} else if (lang.equals("de")) {
return "Hallo, Welt!";
} else {
return "Hello, World!";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.launchcode.java.demos.lsn1datatypes;

import java.util.Scanner;
//import java.util.Scanner;

public class TempConverter {
public static void main(String[] args) {
double fahrenheit;
double celsius;
Scanner input;
java.util.Scanner input;

input = new Scanner(System.in);
input = new java.util.Scanner(System.in);
System.out.println("Enter the temperature in Fahrenheit: ");
fahrenheit = input.nextDouble();
input.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
public class SchoolPractice {
public static void main(String[] args) {
// Instantiate your Student class for part 2 here!
Student amit = new Student("Amit Kapila",3,1,4.0);
}
}
49 changes: 49 additions & 0 deletions src/org/launchcode/java/demos/lsn3classes1/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,55 @@
public class Student {

private String name;

public String getName() {
return name;
}

public Student(String name) {
this.name = name;
}

public Student(String name, int studentId, int numberOfCredits, double gpa) {
this.name = name;
this.studentId = studentId;
this.numberOfCredits = numberOfCredits;
this.gpa = gpa;
}

public int getStudentId() {
return studentId;
}

public void setStudentId(int studentId) {
this.studentId = studentId;
}

public int getNumberOfCredits() {
return numberOfCredits;
}

private void setNumberOfCredits(int numberOfCredits) {
this.numberOfCredits = numberOfCredits;
}

public double getGpa() {
return gpa;
}

public void setGpa(double gpa) {
this.gpa = gpa;
}

public Student(String name, int studentId) {
this.name = name;
this.studentId = studentId;
}

public void setName(String aName) {
name = aName;
}

private int studentId;
private int numberOfCredits = 0;
private double gpa = 0.0;
Expand Down
16 changes: 15 additions & 1 deletion src/org/launchcode/java/demos/lsn4classes2/Course.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.launchcode.java.demos.lsn4classes2;

import java.util.ArrayList;
import java.util.Objects;

public class Course {
private String topic;
Expand All @@ -10,8 +11,21 @@ public class Course {
// TODO: Add your custom 'toString' method here. Make sure it returns a well-formatted String rather than
// just the class fields.

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Course course = (Course) o;
return Objects.equals(topic, course.topic) && Objects.equals(instructor, course.instructor) && Objects.equals(enrolledStudents, course.enrolledStudents);
}

@Override
public int hashCode() {
return Objects.hash(topic, instructor, enrolledStudents);
}


// TODO: Add your custom 'equals' method here. Consider which fields should match in order to call two
// Course objects equal.

}
}