LAB#SE00-1: Maven Person
javase
lab
Maven Person
Basic understanding of Java programming language is required, as well as some familiarity with Maven or Gradle for managing dependencies and building the project. ssl encryption and is intended to run behind a Knowledge of algotighms and data structures to implement the required classes.
Create multiple classes in Java (Person
, Student
, Book
, Car
and Author
) using the most convenient entity relationship between them.
Test these classes using JUnit.
- Create a new Maven or Gradle project and setting up the project structure
- Modify the project’s
pom.xml
orbuild.gradle
file to import necessary dependencies, including JUnit for testing - Implement the required classes in Java
- Implement two basic patter-designs: singleton and think about factory
- Write JUnit tests to verify that classes work as expected
- Allow the user to input data via the console, rather than using
hard-coded test data
in JUnit tests
Approach 1
UML diagram
TODO
Pending to create UML diagram
Classes specifications
Person
Student
Student class
Student.java
package org.labse00part1.domain;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@Data
@Getter
@Setter
@NoArgsConstructor
@ToString(callSuper=true)
public class Student extends Person{
private String university;
private List<Book> books;
private Car car;
@Builder
public Student(String firstName, String lastName, int age, String university) {
super(firstName, lastName, age);
this.university = university;
this.books = new ArrayList<>();
this.car = new Car();
}
@Builder
public Student(String firstName, String lastName, int age, String university, List<Book> books) {
super(firstName, lastName, age);
this.university = university;
this.books = books;
this.car = new Car();
}
@Builder
public Student(String firstName, String lastName, int age, String university, List<Book> books, Car car) {
super(firstName, lastName, age);
this.university = university;
this.books = books;
this.car = car;
}
public void addBook(Book newBook) {
this.books.add(newBook);
}
}
Car
Book
Tests
Use the Code Coverage feature!
When launching tests, do it with Code Coverage to know how much of your code is being tested. Just click on the button next to the Run one when executing a batch of tests or right-click on the Play button next to each test: