Skip to content

Main src/main/java #25

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -15,3 +15,4 @@ public class Course {
// Course objects equal.

}

Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,60 @@ public String studentInfo() {


//TODO: Uncomment and complete the getGradeLevel method here:
// public String getGradeLevel() {
public String getGradeLevel() {
public static String getGradeLevel(int credits) {
if (credits <= 29){
return "freshman";
} else if (credits <= 59){
return "sophomore";
} else if (credits <= 89) {
return "junior";
} else {
return "senior";
}
}
}
// // Determine the grade level of the student based on numberOfCredits
// }

// TODO: Complete the addGrade method.
public void addGrade(int courseCredits, double grade) {
// Update the appropriate fields: numberOfCredits, gpa
public void addGrade(int courseCredits, double grade) {
double totalQualityScore = this.gpa * this.numberOfCredits;
totalQualityScore += courseCredits * grade;
this.numberOfCredits += courseCredits;
this.gpa = totalQualityScore/this.numberOfCredits;
}
}

// TODO: Add your custom 'toString' method here. Make sure it returns a well-formatted String rather
// than just the class fields.

// TODO: Add your custom 'equals' method here. Consider which fields should match in order to call two
// Student objects equal.
public String toString() {

String studentReport = String.format("%s is a %s with %d credits and a GPA of %.2f", this.name, this.getGradeLevel(this.numberOfCredits), this.getNumberOfCredits(), this.getGpa());
return studentReport;
}

public boolean equals(Object toBeCompared) {
if (toBeCompared == this) {
return true;
}

if (toBeCompared == null) {
return false;
}

if (toBeCompared.getClass() != getClass()) {
return false;
}

Student theStudent = (Student) toBeCompared;
return theStudent.getStudentId() == getStudentId();
}

public String getName() {
return name;
Expand Down
37 changes: 37 additions & 0 deletions classes-part-one/exercises/src/main/java/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,41 @@ public class Student {
// Drop your getters and setters below for the Student class.
// To instantiate the Student class, add your code to the main in the file, SchoolPractice.

public void setName(String name) {
this.name = name;
}

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

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

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

public String getName() {
return name;
}

public int getStudentId() {
return studentId;
}

public int getNumberOfCredits() {
return numberOfCredits;
}

public double getGpa() {
return gpa;
}
Student student = new Student("Your Name", 12345, 1, 4.0);
public class Course {
private String topic;
private Teacher instructor;
private ArrayList<Student> enrolledStudents;
}
}
47 changes: 47 additions & 0 deletions classes-part-one/exercises/src/main/java/Teacher.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
public class Teacher {


private String firstname;
private String lastname;
private String subject;
private String yearsTeaching;

public static void main(String[] args) {

}

public String getFirstname() {
return firstname;
}

public void setFirstname(String firstname) {
this.firstname = firstname;
}

public String getLastname() {
return lastname;
}

public void setLastname(String lastname) {
this.lastname = lastname;
}


public String subject () {
return subject;
}

public void setsubject(String subject) {
this.subject = subject;
}

public String yearsTeaching () {
return yearsTeaching;
}

public void setyearsTeaching(String yearsTeaching) {
this.yearsTeaching = yearsTeaching;
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@

public class Main {

public static void main(String[] args) {
public static <MItems> void main(String[] args) {
// write your code here
MItems dessert = new MItems("ApplePie", 4.99 , "Dessert", true);
MItems mCourse = new MItems("Pasta", 10.99 ,"mainCourse", true);
MItems starter = new MItems("AvocadoTaco", 9.99 , "appetizer", true);

dessert.setDescription("Made out of apples");
starter.setDescription("Made out of avocados");
mCourse.setDescription("Made out of cheese and sauce");




}

}





Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.launchcode;

public class Menu2 {
private Date lastUpdated;
private ArrayList<MItems> MItems ;

public Menu2(Date lastUpdated, ArrayList<MItems> MItems) {
this.lastUpdated = lastUpdated;
this.MItems = MItems;
this.lastUpdated = new Date();
}

public Date getLastUpdated() {
return lastUpdated;
}

public ArrayList<org.lauchcode1.MItems> getMItems() {
return MItems;
}

public void setLastUpdated(Date lastUpdated) {
this.lastUpdated = lastUpdated;
}

public void setMItems(ArrayList<org.lauchcode1.MItems> MItems) {
this.MItems = MItems;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package org.launchcode;

public class MItems {
private String itemName;
private double price;
private String description;
private String category;
private boolean isItNew;

public MItems(String itemName, double price, String category, boolean isItNew) {
this.itemName = itemName;
this.price = price;
this.category = category;
this.isItNew = isItNew;
}


public String getItemName() {
return itemName;
}

public double getPrice() {
return price;
}

public String getDescription() {
return description;
}

public String getCategory() {
return category;
}

public boolean isItNew() {
return isItNew;
}

public void setItemName(String itemName) {
this.itemName = itemName;
}

public void setPrice(double price) {
this.price = price;
}

public void setDescription(String description) {
this.description = description;
}

public void setCategory(String category) {
this.category = category;
}

public void setItNew(boolean itNew) {
isItNew = itNew;
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>collections-exercises</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package PACKAGE_NAME;public class ArrayExercise {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.example;

// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args) {
// Press Opt+Enter with your caret at the highlighted text to see how
// IntelliJ IDEA suggests fixing it.
System.out.printf("Hello and welcome!");

// Press Ctrl+R or click the green arrow button in the gutter to run the code.
for (int i = 1; i <= 5; i++) {

// Press Ctrl+D to start debugging your code. We have set one breakpoint
// for you, but you can always add more by pressing Cmd+F8.
System.out.println("i = " + i);
}
}
}
38 changes: 38 additions & 0 deletions control-flow-and-collections/studio/counting-characters/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
Loading