Skip to content

MiramarCISC/cisc191mod1-derr-ng

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date Open in Codespaces

CISC 191 — Module 1 Lab: Array Toolkit + Student Sorting 🧪🐙

Welcome! This repo is your starter code for Module 1.

You will implement:

  • IntArrayToolkit (utility methods for int[])
  • Student (validated data model)
  • StudentArrayToolkit (sorting/searching over Student[])
  • Main (small demo runner for your video)

Autograding: Your score is based on passing the included JUnit tests (run locally with Maven, and on GitHub Actions).


🚨 Required Package (Do Not Change)

All source files must start with:

package edu.sdccd.cisc191;

Your folder structure must match:

src/main/java/edu/sdccd/cisc191/

If your package or folder path differs, autograding will fail.


✅ Requirements Summary

Part A — IntArrayToolkit (all methods are static)

Implement:

  • public static int sum(int[] a)
    • throws IllegalArgumentException if a is null
  • public static int max(int[] a)
    • throws IllegalArgumentException if a is null or empty
  • public static int indexOf(int[] a, int target)
    • returns index of first occurrence, or -1 if not found
    • throws IllegalArgumentException if a is null
  • public static int[] copySortedAscending(int[] a)
    • returns a NEW sorted array (ascending)
    • must NOT modify original
    • throws IllegalArgumentException if a is null

Part B — Student

Fields:

  • name (String), gpa (double), id (int)

Constructor validation:

  • name not null/blank
  • gpa in [0.0, 4.0]
  • id > 0
    Throw IllegalArgumentException if invalid.

Also include:

  • getters
  • toString() readable summary

Part C — StudentArrayToolkit (all methods are static)

Implement:

  • public static Student[] copySortedByGpaDesc(Student[] students)
    • returns a NEW array sorted by GPA descending
    • ties: name ascending
    • must NOT modify original
  • public static Student findByIdLinear(Student[] students, int id)
    • returns matching student or null
  • public static Student[] topNByGpa(Student[] students, int n)
    • returns a NEW array of top N students by GPA desc (ties: name asc)
    • if n > length, return all
    • if n < 0, throw IllegalArgumentException

🪄 Lambda preview required: Sorting must use a Comparator created via lambda or method reference (no anonymous inner classes). (Note: this is graded primarily through peer review, not autograder.)


▶️ How to Run Tests Locally

From terminal:

mvn test

In IntelliJ:

  • Open the Maven tool window
  • Run test

🎥 Video Demo (3–5 minutes)

Show:

  1. Your repo structure + correct package line
  2. Running tests (green)
  3. Running Main and explaining output

Answer these open-ended questions in your video:

  • Q1: Where did you use defensive copying and why does it matter?
  • Q2: Why can a method modify array contents passed into it?
  • Q3: Why is a Comparator lambda useful for sorting objects?
  • Q4: What bug did you hit (or avoid) and how did you debug it?

🤝 Peer Review (Due 1 week after lab deadline)

You will complete peer review via GitHub Pull Request:

  • Make at least 2 meaningful improvements
  • Leave at least 5 review comments
  • PR description should explain what changed and why

✅ AI allowed for feedback-writing only (not for generating your partner’s solution code).


📌 Academic Integrity

Submit your own work. Do not copy from other students or online sources. If you’re unsure whether something is allowed, ask first.

About

2263_mira_cisc-191_24369-cisc191-module-1-CISC191-Module-1-1 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Java 100.0%