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.
ASSIGNMENT LaunchCodeEducation#2: TECH JOBS OO
- Loading branch information
1 parent
9873e51
commit 0c590f3
Showing
8 changed files
with
223 additions
and
163 deletions.
There are no files selected for viewing
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
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,52 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public abstract class JobField { | ||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
public JobField() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
|
||
public JobField(String value) { | ||
this(); | ||
this.value = value; | ||
} | ||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { // Two objects are equal if they have the same id. | ||
if (this == o) return true; | ||
if (!(o instanceof JobField)) return false; | ||
JobField jobField = (JobField) o; | ||
return getId() == jobField.getId(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(getId()); | ||
} | ||
|
||
// Getters and 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
34 changes: 3 additions & 31 deletions
34
src/main/java/org/launchcode/techjobs/oo/PositionType.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,38 +1,10 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
public class PositionType { | ||
import java.util.Objects; | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
public PositionType() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
public class PositionType extends JobField { | ||
|
||
public PositionType(String value) { | ||
this(); | ||
this.value = value; | ||
} | ||
|
||
// TODO: Add a custom toString() method that returns the data stored in 'value'. | ||
|
||
// TODO: Add custom equals and hashCode methods. Consider two PositionType objects "equal" when | ||
// their id fields match. | ||
|
||
// Getters and Setters: | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
super(value); | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
} |
Oops, something went wrong.