Git-Leon 25bd4f19bb Update README.md | 6 jaren geleden | |
---|---|---|
README.md | 6 jaren geleden |
ZipCodeWilmington
class which mediates a composite Students
and Instructors
singleton reference.AnnotationConfigApplicationContext
@Bean
@DependsOn
@Autowired
@PostConstruct
@Config
@SpringBootTest
@Resource
@Configuration
scans from current directory down.LearnerLab
completed in the past until Part 9
Web
in the Search for Dependencies
input boxGenerate Project
pom.xml
from IntelliJ > File > Open
Open as Project
when promptedPerson
ClassPerson
class.
final
field named id
of type long
.name
of type String
.Person
constructor should have a parameter of type long
which sets the id
field to the respective value.getId()
method which returns the Person
object's id
field.getName()
method which returns the Person
object's name
field.setName()
method which sets the Person
object's name
field.-
Learner
InterfaceLearner
interface.
Learner
should declare one method signature:
learn
double numberOfHours
void
-
Student
ClassStudent
class such that:
Student
is a subclass of Person
Student
implements the Learner
interfaceStudent
should have an instance variable totalStudyTime
of type double
Student
should have a concrete implementation of the learn
method which increments the totalStudyTime
variable by the specified numberOfHours
argument.Student
should have a getTotalStudyTime()
method which returns the totalStudyTime
instance variable.-
Teacher
InterfaceCreate a Teacher
interface.
Teacher
should declare a teach
method signature:
teach
Learner learner
double numberOfHours
void
Teacher
should declare a lecture
method signature:
lecture
Learner[] learners
double numberOfHours
void
-
Instructor
ClassInstructor
class such that:
Instructor
is a subclass of Person
Instructor
implements the Teacher
interfaceInstructor
should have a concrete implementation of the teach
method which invokes the learn
method on the specified Learner
object.Instructor
should have a concrete implementation of the lecture
method which invokes the learn
method on each of the elements in the specified array of Learner
objects.
numberOfHours
should be evenly split amongst the learners.
double numberOfHoursPerLearner = numberOfHours / learners.length;
-
Students
Students
class.
People
class.Student
objects upon construction and pass them to the super constructor.-
Instructors
Instructors
class.
People
class.Instructor
objects upon construction and pass them to the super constructor.-
Classroom
Classroom
class.
Instructors
and Students
object upon constructionhostLecture
which makes use of a Teacher teacher, double numberOfHours
parameter to host a lecture
to the composite personList
field in the students
reference.
-
Configuration
classesConfig
classes should have a class-signature annotation of @Configuration
@Bean
definitions within the scope of the class, and register them to the IOC Container for Inject
and Autowire
use later.-
StudentConfig
currentStudents()
which returns a Students
representative of the current cohort of students.
@Bean(name = "students")
@Bean
whose name
attribute is not specified defaults to the name of the method it is annotating.previousStudents()
which returns a Students
representative of the previous cohort of students.-
InstructorsConfig
tcUsaInstructors()
which returns an Instructors
representative of the Tech Connect USA instructors.tcUkInstructors()
which returns an Instructors
representative of the Tech Connect UK instructors.allInstructors
which returns all Instructors
employed at ZipCodeWilmington-
ClassroomConfig
currentCohort()
which returns an Classroom
object whose dependencies are allInstructors
and students
previousCohort()
which returns an Classroom
object whose dependencies are allInstructors
and previousStudents
@DependsOn
annotation to help the compiler and other readers of the code to understand what order beans should be executed.
@DependsOn({"allInstructors", "students"})
-
Config
classesTest
classes should be annotated with
@SpringBootTest
ContextConfiguration
that tells the test class how to load the ApplicationContext
.ContextConfiguration
classes are specified as a parameter to the @SpringBootTest
annotation, the default behavior is to load the ApplicationContext
by scanning for a @SpringBootConfiguration
annotation on a class in the package root.@Autowired
along with @Resource(name = "beanname")
-
StudentConfig
ClassTestStudentConfig
class in the test
package.Bean
in the StudentConfig
class is configured as expected.toString
method to get a representation of the aggregate state of any People
object.-
InstructorConfig
ClassTestInstructorConfig
class in the test
package.Bean
in the TestInstructorConfig
class is configured as expected.-
ClassroomConfig
ClassTestClassroomConfig
class in the test
package.Bean
in the TestClassroomConfig
class is configured as expected.@Component
@Component
allows Spring to register this class as a Bean
implicitly.Alumni
ClassCreate an Alumni
component which autowires Students
of the previous and Instructors
Create an executeBootcamp
method which teaches each Student
in the composite Students
a totalNumberOfHours
of 1200
.
@PostConstruct
-
Alumni
ClassStudent
in the Alumni
class has been taught 1200
hours upon injection of the Alumni
dependency.