rachit-j / ww3

https://rachit-j.github.io/ww3/
MIT License
0 stars 0 forks source link

Tanisha P - Individual Review Ticket #7

Open tanishapatil1234 opened 8 months ago

tanishapatil1234 commented 8 months ago

Demo/Summary Video

Youtube Link

Creating Backend Endpoints - Backend

Generation and Service Classes:

@Configuration
public class CardGeneration {

    @Bean
    CommandLineRunner commandLineRunner(
        CardJpaRepository repository) {
            return args -> {
            List<Card> cards = new ArrayList<>();

            for (int rank = 1; rank <= 500; rank++) {
                Card card = new Card(rank);
                cards.add(card);
            }

            repository.saveAll(cards);
        };
        }

@Service
public class CardService {

    private final CardJpaRepository cardRepository;

    @Autowired
    public CardService(CardJpaRepository cardRepository) {
        this.cardRepository = cardRepository;
    }

    public List<List<Card>> splitCardsRandomly(List<Card> cards) {
        // Shuffle the cards randomly
        Collections.shuffle(cards);

        // Split the cards into two halves
        int halfSize = cards.size() / 2;

        List<Card> firstHalf = new ArrayList<>(cards.subList(0, halfSize));
        List<Card> secondHalf = new ArrayList<>(cards.subList(halfSize, cards.size()));

        List<List<Card>> splitCards = new ArrayList<>();
        splitCards.add(firstHalf);
        splitCards.add(secondHalf);

        return splitCards;
    }
// commit change 

    public void saveCards(List<Card> cards) {
        cardRepository.saveAll(cards);
    }
}
@Repository
public interface CardJpaRepository extends JpaRepository<Card, Long> {
    void save(String Card); 
    List<Card> findByIdIgnoreCase(Long id);
} 

Endpoint:

image

Postman:

image

Key Commit Backend

Creating Test Analysis File - Frontend

image

Key Commit Frontend

Commit History

Frontend:

image

Backend:

image

Retrospective

I plan to add something like ranks so I could add a compareto method as mentioned by Mort in indicator tech talk. Additionally I would create cards as objects with rank and suit variables instead of using an imperative generation method. However we were sort of in a time crunch because we did ideation incorrectly.