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.
- Loading branch information
Showing
7 changed files
with
109 additions
and
218 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.
54 changes: 6 additions & 48 deletions
54
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,55 +1,13 @@ | ||
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++; | ||
} | ||
// CoreCompetency now extends JobField | ||
public class CoreCompetency extends JobField { | ||
|
||
// Constructor that accepts a value and passes it to the superclass | ||
public CoreCompetency(String value) { | ||
this(); | ||
this.value = value; | ||
} | ||
|
||
// Custom toString, equals, and hashCode methods: | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof CoreCompetency)) return false; | ||
CoreCompetency that = (CoreCompetency) o; | ||
return id == that.id; | ||
super(value); // Call to the JobField constructor to initialize the 'value' field | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
// TODO: Use the "Generate" tool to add a getter and setter for the 'value' field but | ||
// ONLY a getter for the 'id' field. | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
// No need to redefine equals, hashCode, toString, getId, or getValue methods, | ||
// since these are inherited from JobField | ||
} |
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,55 +1,12 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
import java.util.Objects; | ||
|
||
public class Employer { | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
public Employer() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
public class Employer extends JobField { | ||
|
||
// Constructor that accepts a value and passes it to the JobField superclass | ||
public Employer(String value) { | ||
this(); | ||
this.value = value; | ||
} | ||
|
||
// Custom toString, equals, and hashCode methods: | ||
|
||
@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 Employer)) return false; | ||
Employer employer = (Employer) o; | ||
return getId() == employer.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; | ||
super(value); // Call the JobField constructor to initialize 'value' | ||
} | ||
|
||
} | ||
// No need to redefine equals, hashCode, toString, getId, or getValue methods, | ||
// since these are inherited from JobField | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
import java.util.Objects; | ||
|
||
|
||
public class Job { | ||
// Field declarations | ||
private int id; | ||
|
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,4 +1,54 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
public class JobField { | ||
} | ||
import | ||
java.util.Objects; | ||
|
||
public abstract class JobField { | ||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
// Constructor initializing only id | ||
public JobField() { | ||
this.id = nextId; | ||
nextId++; | ||
} | ||
|
||
// Constructor initializing id and value | ||
public JobField(String value) { | ||
this(); | ||
this.value = value; | ||
} | ||
|
||
// Getters and setters for 'id' and 'value' | ||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
} | ||
|
||
// Custom equals and hashCode methods, if needed | ||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
JobField jobField = (JobField) o; | ||
return id == jobField.id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return 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,59 +1,16 @@ | ||
package org.launchcode.techjobs.oo; | ||
|
||
// Import Objects utility for equals and hashCode | ||
import java.util.Objects; | ||
|
||
public class Location { | ||
|
||
private int id; | ||
private static int nextId = 1; | ||
private String value; | ||
|
||
public Location() { | ||
id = nextId; | ||
nextId++; | ||
} | ||
// Location now extends JobField | ||
public class Location extends JobField { | ||
|
||
// Constructor that accepts a value and passes it to the superclass | ||
public Location(String value) { | ||
this(); // This calls the default constructor to initialize 'id' | ||
this.value = value; // Assign the passed 'value' to the 'value' field | ||
} | ||
|
||
// TODO: Add a constructor that takes a string as a parameter and assigns it to the 'value' field. The | ||
// constructor should also call the empty constructor in order to initialize the 'id' field. | ||
|
||
|
||
// Custom toString, equals, and hashCode methods: | ||
|
||
@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()); | ||
} | ||
|
||
// Getters and Setters: | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public String getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(String value) { | ||
this.value = value; | ||
super(value); // Call to the JobField constructor to initialize the 'value' field | ||
} | ||
|
||
} | ||
// No need to redefine equals, hashCode, toString, getId, or getValue methods, | ||
// since these are inherited from JobField | ||
} |
Oops, something went wrong.