Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package osu.cse 3 2 4 1 . options; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; import java.util.Set; import osu.cse 3 2 4 1 . utilities.Utilities; import

package osu.cse3241.options;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
import osu.cse3241.utilities.Utilities;
import osu.cse3241.sql.SQL;
import osu.cse3241.GRS;
public class EditMenu {
private static final Set MENU_OPTIONS = new HashSet<>(Arrays.asList('1','2','3','x'));
public static void menu(Scanner cin){
Utilities.printDivider();
System.out.print("EDIT MENU:
"
+"1. Add Artist
"
+"2. Delete Artist
"
+"3. Update Artist
"
+ "Input numerical selection (or 'x' to quit): ");
String input = cin.nextLine();
char selection =!input.isEmpty()? input.charAt(0) : '';
while(!MENU_OPTIONS.contains(selection)){
System.out.print("Incorrect option specified! Try again: ");
input = cin.nextLine();
selection =!input.isEmpty()? input.charAt(0) : '';
}
switch(selection){
case '1':
addArtist();
break;
case '2':
deleteArtist();
break;
case '3':
updateArtist();
default:
break;
}
}
/*
* PART SEVEN:
* Complete the method addArtist() below and remove its placeholder.
*
* Your implementation will follow the general procedure:
*1) Prompt the user for values for each column in the ARTIST table.
*2) Call a method in SQL.java which will handle the insertion of data
* via PreparedStatement and will print out a confirmation message
* upon successful insertion. You will need to define this method in SQL.java!
*
* Note: since this query is not returning anything (like a SELECT query), we need to use
* a different method here (see JDBC_API slide deck): PreparedStatement.executeUpdate(). This also has the possibility to
* throw a SQL Exception (like many other methods you have already used), so make sure it is
* handled in much the same way as the other Statement/PreparedStatement methods are handled!
*
* You are free to design the input prompt, and the method on SQL.java to insert the data, etc.
*/
private static void addArtist(){
Utilities.placeholder();
/* TODO */
}
private static void deleteArtist(){
Utilities.placeholder();
}
private static void updateArtist(){
Utilities.placeholder();
}
}
fill in the todo

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions