forked from LaunchCodeEducation/techjobs-oo-java-graded-17
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
graded assignment LaunchCodeEducation#2 --> all tests pass, needs one…
… more refactor
- Loading branch information
Showing
9 changed files
with
187 additions
and
188 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
82 changes: 34 additions & 48 deletions
82
src/main/java/org/launchcode/techjobs/oo/CoreCompetency.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,39 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public class CoreCompetency { | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
public CoreCompetency() { | ||
this.id = nextId; | ||
nextId++; | ||
} | ||
|
||
public CoreCompetency(String value) { | ||
this(); // initializes id by default | ||
this.value = value; | ||
} | ||
|
||
public class CoreCompetency extends JobField { | ||
|
||
// private int id; | ||
// private static int nextId = 1; | ||
// private String value; | ||
// //////////////////////////////////////////////////////////////////////////// | ||
// public CoreCompetency() { | ||
// this.id = nextId; | ||
// nextId++; | ||
// } | ||
public CoreCompetency(String value) { super(value); } | ||
|
||
// public CoreCompetency(String value) { | ||
// this(); // initializes id by default | ||
// this.value = value; | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
// objects are equal if share same id | ||
if (this == o) return true; | ||
if (!(o instanceof CoreCompetency)) return false; | ||
CoreCompetency skill = (CoreCompetency) o; | ||
return id == skill.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
// @Override | ||
// public boolean equals(Object o) { | ||
// // objects are equal if share same id | ||
// if (this == o) return true; | ||
// if (!(o instanceof CoreCompetency)) return false; | ||
// CoreCompetency skill = (CoreCompetency) o; | ||
// return id == skill.id; | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
// public int getId() { | ||
// return id; | ||
// } | ||
// | ||
// public String getValue() { | ||
// return value; | ||
// } | ||
// public void setValue(String value) { | ||
// this.value = value; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,42 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public class Employer { | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
public class Employer extends JobField { | ||
|
||
// private int id; | ||
// private static int nextId = 1; | ||
// private String value; | ||
//////////////////////////////////////////////////////////////////////////// | ||
public Employer() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
// public Employer() { | ||
// id = nextId; | ||
// nextId++; | ||
// } | ||
|
||
public Employer(String value) { | ||
this(); // initializes id by default | ||
this.value = value; | ||
super(value); | ||
} | ||
|
||
// public Employer(String value) { | ||
// this(); // initializes id by default | ||
// this.value = value; | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
// objects sharing same id are equal | ||
if (this == o) return true; | ||
if (!(o instanceof Employer)) return false; | ||
Employer employer = (Employer) o; | ||
return getId() == employer.getId(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getId()); | ||
} | ||
|
||
// @Override | ||
// public String toString() { return value; } | ||
|
||
// @Override | ||
// public boolean equals(Object o) { | ||
// // objects sharing same id are equal | ||
// if (this == o) return true; | ||
// if (!(o instanceof Employer)) return false; | ||
// Employer employer = (Employer) o; | ||
// return getId() == employer.getId(); | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
public int getId() { return id; } | ||
|
||
public String getValue() { return value; } | ||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
// getters & setters: | ||
// public int getId() { return id; } | ||
// | ||
// public String getValue() { return value; } | ||
// public void setValue(String value) { | ||
// this.value = value; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class JobField { | ||
// fields, constructors, getters/setters, custom methods ALL FOUR classes share | ||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
public JobField(String value) { | ||
this.value = value; | ||
id = nextId; | ||
nextId++; | ||
} | ||
//////////////////////////////////////////////////////////////////////////// | ||
@Override | ||
public int hashCode() { return Objects.hash(getId()); } | ||
|
||
@Override | ||
public String toString() { return value; } | ||
|
||
@Override // job1.equals(job2) | ||
public boolean equals(Object obj) { | ||
// this refers to job1 & obj refers to job2 | ||
if (this == obj) { return true; } | ||
if (!(obj instanceof JobField)) { return false; } | ||
// casting Object obj to JobField type | ||
JobField jobVar = (JobField) obj; | ||
// equivalent objects have same id | ||
return id == jobVar.id; | ||
} | ||
//////////////////////////////////////////////////////////////////////////// | ||
public int getId() { return id; } | ||
|
||
public String getValue() { return value; } | ||
public void setValue(String value) { this.value = value; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,35 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public class Location { | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
public class Location extends JobField { | ||
|
||
// private int id; | ||
// private static int nextId = 1; | ||
// private String value; | ||
//////////////////////////////////////////////////////////////////////////// | ||
public Location() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
|
||
public Location(String value) { | ||
this(); // initializes id by default | ||
this.value = value; | ||
} | ||
|
||
// public Location() { | ||
// id = nextId; | ||
// nextId++; | ||
// } | ||
public Location(String value) { super(value); } | ||
|
||
// public Location(String value) { | ||
// this(); // initializes id by default | ||
// this.value = value; | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof Location)) return false; | ||
Location location = (Location) o; | ||
return getId() == location.getId(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getId()); | ||
} | ||
|
||
// @Override | ||
// public boolean equals(Object o) { | ||
// // objects are equal if share same id | ||
// if (this == o) return true; | ||
// if (!(o instanceof Location)) return false; | ||
// Location location = (Location) o; | ||
// return getId() == location.getId(); | ||
// } | ||
//////////////////////////////////////////////////////////////////////////// | ||
public int getId() { return id; } | ||
|
||
public String getValue() { return value; } | ||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
// public int getId() { return id; } | ||
// | ||
// public String getValue() { return value; } | ||
// public void setValue(String value) { | ||
// this.value = value; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.