Skip to content

Commit

Permalink
up to task 3 on java GA LaunchCodeEducation#2
Browse files Browse the repository at this point in the history
  • Loading branch information
Turnerc7 committed Oct 7, 2024
1 parent 75c5667 commit 87c22e1
Show file tree
Hide file tree
Showing 8 changed files with 309 additions and 55 deletions.
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

193 changes: 162 additions & 31 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions src/main/java/org/launchcode/techjobs/oo/CoreCompetency.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,30 @@ public boolean equals(Object o) {
return id == that.id;
}

public static int getNextId() {
return nextId;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public int getId() {
return id;
}

// public void setId(int id) {
// this.id = id;
// }
//
// public static void setNextId(int nextId) {
// CoreCompetency.nextId = nextId;
// }

@Override
public int hashCode() {
return Objects.hash(id);
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/launchcode/techjobs/oo/Employer.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ public Employer() {

public Employer(String value) {
this();
this.value = value;
setValue(value);
// if (value == null || value.trim().isEmpty()) {
// this.value = "Unknown";
// } else {
// this.value = value;
// }
}

// Custom toString, equals, and hashCode methods:

@Override
Expand Down
81 changes: 72 additions & 9 deletions src/main/java/org/launchcode/techjobs/oo/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,87 @@

import java.util.Objects;

public class Job {

public class Job {
private int id;
private static int nextId = 1;

private String name;
private Employer employer;
private Location location;
private PositionType positionType;
private CoreCompetency coreCompetency;

// TODO: Add two constructors - one to initialize a unique ID and a second to initialize the
// other five fields. The second constructor should also call the first in order to initialize
// the 'id' field.
// Default constructor to initialize unique ID
public Job() {
this.id = nextId;
nextId++;
}

// Constructor to initialize all fields
public Job(String name, Employer employer, Location location, PositionType positionType, CoreCompetency coreCompetency) {
this();
this.name = Objects.requireNonNull(name, "Name cannot be null");
this.employer = Objects.requireNonNull(employer, "Employer cannot be null");
this.location = Objects.requireNonNull(location, "Location cannot be null");
this.positionType = Objects.requireNonNull(positionType, "PositionType cannot be null");
this.coreCompetency = Objects.requireNonNull(coreCompetency, "CoreCompetency cannot be null");
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Job job = (Job) o;
return id == job.id;
}

@Override
public int hashCode() {
return Objects.hash(id);
}

public int getId() {
return id;
}

// Getters and Setters
public String getName() {
return name;
}

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

public Employer getEmployer() {
return employer;
}

public void setEmployer(Employer employer) {
this.employer = employer;
}

public Location getLocation() {
return location;
}

public void setLocation(Location location) {
this.location = location;
}

public PositionType getPositionType() {
return positionType;
}

public void setPositionType(PositionType positionType) {
this.positionType = positionType;
}

// TODO: Add custom equals and hashCode methods. Consider two Job objects "equal" when their id fields
// match.
public CoreCompetency getCoreCompetency() {
return coreCompetency;
}

// TODO: Add getters for each field EXCEPT nextId. Add setters for each field EXCEPT nextID
// and id.
public void setCoreCompetency(CoreCompetency coreCompetency) {
this.coreCompetency = coreCompetency;
}
}
Loading

0 comments on commit 87c22e1

Please sign in to comment.