CS I · Thu Nov 19 · 16.4 · We Do

Before the bell

You are responsible for all of this before the end of class.

  1. The discussion form in the I Do deck. All three sections. If you are here, this should be done.
  2. Your classwork. This form on the right. Section 1 before the exit ticket pops up; Section 2 past the floor.
  3. Today's Bench Basics activity: Read the Signature. It opens later in class and lives on slide 4 of this deck.
  4. The exit ticket. It opens 15 minutes before the bell and lives on the last slide of this deck.
Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Read the Signature

This reading shows how to read the first line of a method, so that a reader can predict what a call to it will do before tracing it.

One Worked Example

The first line of a method is its header. The header names the type of value the method returns, the method's name and its parameters in parentheses. Oracle's Java tutorial calls the method's name and its parameter types the method's signature. The program below has two methods above main, and a comment sits on the line above each one. Java ignores everything from // to the end of a line, so a comment changes nothing when the program runs.

1public class Main {
2    // Returns the total of two whole numbers.
3    public static int add(int a, int b) {
4        return a + b;
5    }
6
7    // Prints a label and a value on one line.
8    public static void show(String label, int value) {
9        System.out.println(label + ": " + value);
10    }
11
12    public static void main(String[] args) {
13        int sum = add(4, 9);
14        show("Sum", sum);
15        show("Double", add(sum, sum));
16    }
17}
Sum: 13
Double: 26

The return type int on line 3 means that add hands a whole number back to the line that called it, as Wednesday's bench showed with return. The table below labels each header, on lines 3 and 8.

Part        | add (line 3)  | show (line 8)
return type | int           | void
name        | add           | show
parameters  | int a, int b  | String label, int value

The parameters are the names in the header, and the arguments are the values in a call. Java matches them in order, first to first and second to second. An argument can be a plain value such as 4, a variable such as sum, or another call such as add(sum, sum). In every case, Java works out the argument's value before that value goes into its parameter.

Call                           | Arguments                | Parameters get
add(4, 9)          (line 13)   | 4, 9                     | a is 4, b is 9
show("Sum", sum)   (line 14)   | "Sum", sum               | label is "Sum", value is 13
add(sum, sum)      (line 15)   | sum, sum                 | a is 13, b is 13
show(...)          (line 15)   | "Double", add(sum, sum)  | label is "Double", value is 26

Predict, Then Trace

The comment on line 2 says that add returns a total, so a reader can predict that add(4, 9) gives 13 without tracing it. Line 13 stores that 13 in sum. The comment on line 7 says that show prints a label and a value, so line 14 should print Sum: 13. On line 15, Java works out the inner call first, add(13, 13), which returns 26, and then show prints Double: 26. The trace confirms both predictions, and the output above matches them.

Two Mistakes the Bench Catches

The first mistake is calling a parameter an argument. In line 3, a and b are parameters, and in line 13, 4 and 9 are the arguments. The second mistake is reading void as "does nothing." The word void means only that show returns no value, and show still prints a line each time it is called. Today's bench, B19 Read the Signature, asks students to click the return type, the name, the parameter and the argument, and to choose the comment that matches a method.

Sources: Oracle, Defining Methods, Passing Information to a Method and Returning a Value from a Method (n.d.); Oracle, The Java Language Specification, Java SE 21, §3.7 and §8.4 (2023); classroom data, B19 Read the Signature and the worked example run with Java 21 (2026).

One Question to Code Coach

This section follows one real Code Coach request, captured on October 19, 2026, from the Ask button to the model and back.

From the Bench Page to the Class Endpoint

Code Coach is the tool inside Bench Basics that explains a short piece of Java. On a job with code, its panel opens only after the student has checked an answer, so the student predicts first and asks second. The student then picks the whole code or one line from a list, and the bench writes the question. The bench page runs in the browser on the student's Chromebook, so the bench page is the client. When the student presses Ask, the page sends a request to the class endpoint at muggsofcompsci.net/api/class/ask. In the request, the field named tool holds the student's course code, the field named system holds Code Coach's system prompt, and the field named input holds the numbered code and the question.

The input from that request is below, numbered as the bench's code panel numbers it.

1  int score = 17;
2  int bonus = score % 5;
3  if (score + bonus > 20)
4  {
5      System.out.println("high");
6  }
7  else
8  {
9      System.out.println("low");
10 }
11 System.out.println(score + bonus);

Question: What does line 3 do?

A pick left empty is the contrast case for a request. If the student presses Ask without picking the whole code or a line, the bench shows the message "Paste or pick a line first" and no request leaves the page.

Two Servers Pass the Request Along

The class endpoint is a server, a program on Cloudflare's network that waits for requests and answers them. First, it checks the request against its limits. The input must not be empty or longer than 2,000 characters, the course code must be valid, and each student gets 12 runs in each class period. Next, the endpoint runs Mistral's moderation check on the system prompt and the input, which looks for content that is not appropriate for school. Then it puts a short school-safety line in front of the system prompt, adds the API key from Wednesday's lesson, and passes the request on to Mistral's API at api.mistral.ai. Mistral's computers are the second server, and the model, mistral-small-2603, runs there. The request to Mistral holds two messages: a system message with the safety line and the system prompt, and a user message with the student's input.

The bench page is the contrast case for a server. The page in the browser holds no model and no API key, so it cannot generate an explanation by itself. Figure 1 shows the whole path, through both servers and back.

The Response Comes Back

The model generates the explanation and returns it in Mistral's response. Mistral's server sends the response to the class endpoint, which runs the moderation check on the answer and passes the text back to the bench page. The bench shows the text under the job, labeled as generated by a model and to be checked against the code. The October 19 request was run twice, and this is the first explanation, word for word.

Line 3 checks if the sum of `score` (17) and `bonus` (calculated in line 2) is greater than 20.
It calculates `17 + bonus` and compares it to 20.
If true, it runs lines 5–6; if false, it runs lines 9–10.

The explanation describes line 3 correctly, but it never gives the value of bonus. Line 2 stores 2 in bonus, because 17 divided by 5 leaves a remainder of 2, so the sum is 19 and the program prints low. If the class endpoint does not answer, the bench shows a note that begins "Code Coach did not answer," and every job on the bench still works without it.

What the System Prompt Does

A system prompt is the builder's instructions, sent to the model with every request. Code Coach's system prompt has six lines, and the bench page puts the same six lines in the system field of every request it sends. The October 23 lesson said that in MuggsAI, the server adds the system prompt. In the tools that use the class endpoint, the page sends the system prompt, and the endpoint passes it on with a safety line in front. Either way, the student never sees those lines, but the model receives them each time, so they shape every answer. For example, line 4 serves R3, the requirement that Code Coach does not write new code for the student.

Do not write new code for the student, and do not rewrite the student's code.

The student's question is the contrast case for the system prompt. The question changes from one request to the next, because a student picks a different line or job. The system prompt stays the same in every request. The builder controls the bench page and the system prompt, but the builder does not control the exact words the model generates. The second explanation of the same request described line 3 in different words.

Summary

A Code Coach question starts as a request from the bench page, which is the client. The class endpoint, a server, checks the request, adds the API key and passes it to Mistral's server, where the model runs, and the response comes back the same way. The system prompt travels in every request, so it shapes every answer even though the student never sees it.

Sources: MDN Web Docs, Overview of HTTP (2026); MDN Web Docs, Client-server overview (2026); Mistral AI, Chat completions (n.d.); CS I passages, Clients, Servers and Requests and The Parts of an AI Tool (2026); Code Coach bench code, class endpoint code and system prompt, course repository (2026); Code Coach captured request, exam-line3-numbered (2026).

Classwork · Section 1 — Reading 2

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

MC 1. When a student asks Code Coach a question, what plays the role of the client?

  • The class endpoint, because it receives the question first
  • The bench page, which runs in the browser on the Chromebook
  • Mistral's server, because it sends the explanation back
  • The model, because the explanation comes from it

MC 2. A Code Coach request passes through two servers. On which one does the model run?

  • The class endpoint, because it adds the API key
  • The Chromebook, because the explanation appears there
  • Mistral's server, reached at api.mistral.ai
  • Neither server, because the bench page keeps a copy of the model

MC 3. What does the bench page's request to the class endpoint carry?

  • The API key, the system prompt and the question
  • Only the question, such as "What does line 3 do?"
  • The explanation, so the class endpoint can check it
  • The course code, the system prompt, and the numbered code with the question

MC 4. A student asks Code Coach about line 2 of one job and then about line 5 of another job. What is the same in both requests?

  • The six lines of Code Coach's system prompt
  • The numbered code in the input
  • The question at the end of the input
  • The explanation the model sends back

MC 5. What is the return type of the method half?

1public class Main {
2    public static double half(int n) {
3        return n / 2.0;
4    }
5
6    public static void main(String[] args) {
7        System.out.println(half(7));
8    }
9}
  • int, because the parameter n is an int
  • double
  • half, because it comes just before the parentheses
  • static, because it comes just before the return type

MC 6. What are the parameters of the method label?

1public class Main {
2    public static String label(String word, int number) {
3        return word + " " + number;
4    }
5
6    public static void main(String[] args) {
7        System.out.println(label("Table", 4));
8    }
9}
  • "Table" and 4
  • String word and int number
  • String, because the method returns a String
  • word + " " + number

MC 7. What are the arguments in the call to total on line 7?

1public class Main {
2    public static int total(int x, int y) {
3        return x + y;
4    }
5
6    public static void main(String[] args) {
7        int t = total(8, 5);
8        System.out.println(t);
9    }
10}
  • x and y
  • int x and int y
  • 8 and 5
  • t, because t gets the value

MC 8. Which comment correctly describes the method square?

1public class Main {
2    public static int square(int n) {
3        return n * n;
4    }
5
6    public static void main(String[] args) {
7        System.out.println(square(6));
8    }
9}
  • // Prints n times n.
  • // Returns n plus n.
  • // Returns n times n.
  • // Returns true if n is a square number.

MC 9. What does this program print?

1public class Main {
2    public static int triple(int n) {
3        return n * 3;
4    }
5
6    public static void main(String[] args) {
7        int k = triple(4);
8        System.out.println(k + 1);
9    }
10}
  • 12
  • 13
  • 15
  • k + 1

MC 10. Which header belongs to a method that returns no value?

  • public static int count(String word)
  • public static double average(int a, int b)
  • public static void greet(String name)
  • public static String twice(String word)

CR 1. Label the return type, the name and the parameters of the method seats, and the arguments in the call on line 8. Then write what the program prints.

1public class Main {
2    // Returns the number of seats in a given number of rows.
3    public static int seats(int rows, int perRow) {
4        return rows * perRow;
5    }
6
7    public static void main(String[] args) {
8        System.out.println(seats(6, 4));
9    }
10}

Write your answer in your lab notebook, labeled CR 1.

CR 2. Explain in two sentences why the system prompt shapes every Code Coach answer even though the student never sees it.

Write your answer in your lab notebook, labeled CR 2.

Figure 1. One Code Coach question, drawn from the endpoint's code: the bench page sends a request with the system prompt in it to the class endpoint, which adds the API key and passes it to Mistral's server, and the response comes back the same way to the job.
Classwork · Section 2 — Past the floor

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

CR 3. Write a one-line comment for the method minutes that says what it does. Then predict what the two calls on lines 7 and 8 print, and explain how you got each one.

1public class Main {
2    public static int minutes(int hours) {
3        return hours * 60;
4    }
5
6    public static void main(String[] args) {
7        System.out.println(minutes(2));
8        System.out.println(minutes(3) + 15);
9    }
10}

Write your answer in your lab notebook, labeled CR 3.

CR 4. The class endpoint is down for the whole period. Say what a student sees on the bench after pressing Ask, and say which bench jobs still work. Use the passage.

Write your answer in your lab notebook, labeled CR 4.

Bench Basics

Read the Signature

Open the bench, do its six jobs, then paste your credit code into the credit-code form. You can turn in up to three codes per bench; your best score is your grade.

Bench Basics opens during your class period.

Classwork

The classwork form is not linked yet. Use Station View and write your answers in your lab notebook with the item labels.

Exit Ticket

This opens during your class period.