```python def register_user(username, password): """ Registers a new user. Args: username (str): The username of the new user. password (str): The password of the new user. Raises: ValueError: If the username is already taken. """ Check if the username is already taken if username in users: raise ValueError("Username already taken") Create a new user object user = User(username, password) Add the new user to the list of users users.append(user) ``` J影音a: ```j影音a public void registerUser(String username, String password) { // Check if the username is already taken if (users.containsKey(username)) { throw new IllegalArgumentException("Username already taken"); } // Create a new user object User user = new User(username, password); // Add the new user to the map of users users.put(username, user); } ``` C: ```csharp public void RegisterUser(string username, string password) { // Check if the username is already taken if (users.ContainsKey(username)) { throw new ArgumentException("Username already taken"); } // Create a new user object User user = new User(username, password); // Add the new user to the dictionary of users users.Add(username, user); } ``` PHP: ```php public function registerUser(string $username, string $password) { // Check if the username is already taken if (isset($this->users[$username])) { throw new Exception("Username already taken"); } // Create a new user object $user = new User($username, $password); // Add the new user to the array of users $this->users[$username] = $user; } ```
```j影音a import com.google.cloud.bigquery.BigQuery; import com.google.cloud.bigquery.BigQueryException; import com.google.cloud.bigquery.BigQueryOptions; import com.google.cloud.bigquery.Job; import com.google.cloud.bigquery.JobInfo; import com.google.cloud.bigquery.QueryJobConfiguration; import com.google.cloud.bigquery.TableResult; public class QueryUsingLegacySql { public static void main(String[] args) { // TODO(developer): Replace these variables before running the sample. String query = String.format( "SELECT accountNumber, bankCode FROM `bigquery-public-data.transactions.us_states`" + " WHERE accountNumber LIKE '%06530465%'"); String projectId = "bigquery-public-data"; queryUsingLegacySql(projectId, query); } public static void queryUsingLegacySql(String projectId, String query) { try { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. BigQuery bigquery = BigQueryOptions.getDefaultInstance().getService(); QueryJobConfiguration queryConfig = QueryJobConfiguration.newBuilder(query) .setUseLegacySql(true) .build(); // Example query to find customers by name from the "us_states" dataset. Job job = bigquery.create(JobInfo.of(queryConfig)); // Wait for the query to complete. job = job.waitFor(); // Check for errors if (job.isDone()) { TableResult results = job.getQueryResults(); results .iterateAll() .forEach(row -> row.forEach(val -> System.out.printf("%s,", val.toString()))); } else { System.out.println("Job not executed since it no longer exists."); } } catch (BigQueryException | InterruptedException e) { System.out.println("Query not performed \n" + e.toString()); } } } ```