id
stringlengths
36
36
text
stringlengths
1
1.25M
e08a18c4-d2e6-4245-bb08-477ed7786911
@Override public boolean setVolume(float value) { if(soundClip.isControlSupported(FloatControl.Type.VOLUME)) { FloatControl volume = (FloatControl) soundClip.getControl(FloatControl.Type.VOLUME); volume.setValue(value); return true; } else if(soundClip.isControlSupported(FloatControl.Type.MASTER_GAIN)) { FloatControl volume = (FloatControl) soundClip.getControl(FloatControl.Type.MASTER_GAIN); volume.setValue(value); return true; } return false; }
f47427a4-4171-4f4f-8101-522de4799ea5
@Override public void setRepeat(boolean repeat) { repeating = repeat; if(repeat) { soundClip.loop(Clip.LOOP_CONTINUOUSLY); soundClip.setLoopPoints(0, -1); } else { soundClip.loop(0); } }
bb67a561-274a-485f-812f-d3c68cceb2f4
public abstract void start();
39de1dbb-25ea-4bc4-ab5c-a9514eb7ef50
public abstract void stop();
1d63ed22-f30f-4a1c-8443-193a02c46f46
public abstract void pause();
571374d3-f2f1-42bc-af61-bdcd53e4171a
public abstract boolean setVolume(float value);
c87692a2-7d4f-4be1-b2df-8a246c2f3275
public abstract void setRepeat(boolean repeat);
306397b5-df3c-440f-8409-85876eab7d5e
public String getPath() { return soundFile.getPath(); }
d3927123-091c-43bf-89ad-4a0a233f5a8f
public boolean isPlaying() { return playing; }
eba3aa3f-ccf4-4fd4-81ba-cc647701a86d
public boolean isRepeating() { return repeating; }
137649fb-239f-4aeb-b270-5bc2ea42f5ac
public TextFileRead(File file){ //this.file=file; //this.type=type; this.file=file; }
3bf0c3f2-3863-4dac-8f4c-a50b4a650f23
public String textToString() { StringBuilder s= new StringBuilder(); try{ Scanner sc=new Scanner(file); sc.nextLine(); while (sc.hasNextLine()) { s.append(sc.nextLine()); } sc.close(); } catch(IOException e){ } return s.toString(); }
ab6ddf8d-3bd0-4a1b-b120-ce0874905602
public boolean addToText(String s){ try { BufferedWriter out = new BufferedWriter(new FileWriter(file)); out.newLine(); out.append(s); out.close(); return true; } catch (IOException e) { //System.out.print("you fail"); return false; } }
d9cf52e9-1636-490e-a423-71e0fa31cb8c
public String getUsername(){ return null; }
5a4c80ce-2595-4947-a53c-e179fc09e565
public int getStartdate(){ return (Integer) null; }
5caf777d-ba92-498b-a52c-5a8f0d68b2e2
public boolean setGoal (Goal goal){ //text file in the form: //username; startdate; enddate; goaltype /* try { BufferedWriter out = new BufferedWriter(new FileWriter(goalFile,true)); out.newLine(); out.append(username + ";" + goaltype + ";" + startdate + ";" + enddate + ";"); out.close(); return true; } catch (IOException e) { //System.out.print("you fail"); return false; } */ boolean r = tfr.addToText(goal.toString()); System.out.print("in set Goal " + tfr.textToString()); return r; }
6b3e7b04-c58e-48c5-bc5f-0aaafd0db3f7
public Goal (File file){ //File goalFile= new File ("Goal.txt"); tfr = new TextFileRead(file); }
54a02652-7b26-4ceb-8705-0481cd10f194
public String toString(){ return username + " " + goaltype + " " + startdate + " " + enddate + " "; }
39b3057d-e828-4393-8128-9ab18451c937
public Goal (String username, String goaltype, int startdate, int enddate){ this.username=username; this.goaltype=goaltype; this.startdate=startdate; this.enddate=enddate; }
0dcee9e1-1911-4ac7-8bed-ac6ed75877b8
public String getUsername() { return username; }
8ce83bea-6b48-4bb3-be6b-289107bfe264
public void setUsername(String username) { this.username = username; }
b50b1fe2-9e66-464a-bd6a-c92b503a05f4
public Goal[] getGoal() { int ctr=0; String s = tfr.textToString(); System.out.print(s); String[] tokens = s.split(";"); Goal[] goal = new Goal[500]; System.out.print(tokens.length); while(ctr+3<tokens.length){ goal[ctr] = new Goal(tokens[ctr], tokens[ctr+1], Integer.parseInt(tokens[ctr+2].trim()), Integer.parseInt(tokens[ctr+3].trim())); System.out.println(goal.toString()); System.out.print("CTR is " + ctr); ctr=ctr+4;; } return goal; }
890067e8-1efd-429f-b6a6-07992cff2f0f
public static void main(String[] args) { // TODO Auto-generated method stub File goalFile = new File("Goal.txt"); Goal goal = new Goal(goalFile); goal.setGoal(new Goal("Liz","BeAwesome",1234,56789)); goal.getGoal(); goal.setGoal(new Goal("Sue","RunMaybe",1234,56789)); goal.getGoal(); //goal.getGoal("random user",goalFile); }
33b26478-07b3-4fa5-afe6-9b29fce3f3b2
public Activity( Date d, Date dur, String ttl, String n, String u) { super (ttl, u); date = d; duration = dur; note = n; }
41dfc347-c5e9-4df0-ac9e-b3bbb51b44d0
public Activity (String u) { super(u); duration = null; note = ""; }
bb7b4eee-1078-4f09-be59-fdf06a966768
public Activity (Activity a) { super(a); date = a.date; duration = a.duration; note = a.note; }
ca96a5e5-cfe5-4d37-95fd-69944d0ae8d6
public void setDate (Date d) { this.date = d; }
438eaa67-d77a-4386-9b06-7fa3717b5610
public void setDuration (Date d) { this.duration = d; }
46ad7970-ad68-4715-b1e3-d20bfc02e4c1
public void setNote (String n) { this.note = n; }
8f8aab9a-1344-4822-9bc7-795c29c4c157
public Date getDate() { return date; }
1e280bf7-4a01-4aea-be35-153a74983d37
public Date getDuration() { return duration; }
89b6ce13-26b2-4b64-8522-e0b2f455b721
public String getNote() { return note; }
a8e4b917-aaf9-44b8-96c2-bfdb50735edd
public String toString() { return getUsername() + "," + date + "," + getTitle() + "," + getType() + "," + duration; }
f5eaea8e-1c9a-4325-8ca3-4bfe2c76af1e
public GenericActivity(String u) { type = "running"; title = "Running"; username = u; }
d70eaa76-dea9-4973-aa8c-8cb26bc17222
public GenericActivity( String ttl, String u) { title = ttl; username = u; }
efddb0fa-fe7c-4243-8000-46a520e12e74
public GenericActivity (GenericActivity g) { type = g.type; title = g.title; username = g.username; }
92c43f89-bc8b-41c9-8de7-c585b5abfcb8
public void setGenericActivity( String ttl, String u ) { //set default title if none provided if (ttl == ""){ title = "Running"; } else { title = ttl; } username = u; }
2cc8ea47-79cb-4b00-8441-7d39b41e5f60
public void setUsername(String u){ username = u; }
1e3401e5-a0b4-4094-866d-7ae0466d5479
public void setTitle(String t){ title = t; }
0a61f562-ec00-4bce-a1b5-7aad5f5438d6
public String getType() { return type; }
7981535c-b1d0-49a5-9b7a-f39fab4169d1
public String getTitle() { return title; }
8dc7894a-3f97-415e-8f88-30e1998bc94a
public String getUsername() { return username; }
727b4d13-a332-41ff-a6ff-ce21f0b4b5f6
public String toString() { return username + "," + title + "," + type; }
9f4042b5-1040-4745-a81b-c46c80e6419b
public Schedule (int d, String a, String u, float dist, String ttl) { super (ttl, u); day = d; distance = dist; }
9e644583-8ffd-4f39-93aa-0794c6ceb3ec
public Schedule (Schedule s) { super(s); day = s.day; distance = s.distance; }
b7564fb5-1108-4560-86c0-04da3ec3bb38
public void setSchedule( int d, String u, float dist, String t ) { day = d; distance = dist; this.setUsername(u); this.setTitle(t); }
63c29e42-883a-48ac-86fd-ef360a9de3a2
public int getDay() { return day; }
57018a3f-7d61-4b87-bf50-bb584f9efc07
public float getDistance() { return distance; }
0a3d9330-1c26-4bd6-b4d6-832dc7dc6556
public String toString() { return getUsername() + "," + day + "," + getTitle() + "," + getType() + "," + distance; }
96c9662e-242f-487e-813d-43a106412a0d
public GenericActivityFile (){ objectlist = new LinkedList<E>(); objectnavigator = objectlist.listIterator(); filename = "empty.txt"; }
fd10a828-76fe-4090-a0f1-82434c0f473c
@SuppressWarnings("unchecked") public void readObjectFile(String fn) throws IOException{ this.setFilename(fn); File file = new File(filename); if (file.exists()) { try { f = new FileInputStream(file); o = new ObjectInputStream(f); try { do { objectlist.add((E) o.readObject()); }while(f.available() > 0); } catch (EOFException e) { System.err.println("End of file reached"); } catch (ClassNotFoundException e) { System.err.println("Class does not exist"); } } catch (FileNotFoundException e) { System.err.println("File not found exception"); } catch (IOException e) { System.err.println("IO exception in reader. Filename is".concat(filename)); } catch (NullPointerException e) { System.err.println("Null pointer exception"); } finally { o.close(); } } //else throw new NullPointerException(); }
32e35238-035d-4e1a-ac30-caebe8d2ab62
public void writeObjectFile() throws IOException{ File file = new File(filename); ListIterator<E> iterate = objectlist.listIterator(0);//start at the first item System.out.print(objectlist.size()); try { g = new FileOutputStream(file); p = new ObjectOutputStream(g); try { do { p.writeObject(iterate.next()); } while(iterate.hasNext()); } catch (EOFException e) { System.err.println("End of file reached"); } } catch (FileNotFoundException e) { System.err.println("File not found exception"); } catch (IOException e) { System.err.println("IO exception. Filename is".concat(filename)); } finally { p.close(); } }
761d7967-4ad2-479f-b101-ac8b6b9df47e
public E getNext() { if (objectnavigator.hasNext()) return objectnavigator.next(); else return null; }
8d1e336b-d23f-48d6-a712-a531e62b4f8e
public E getPrevious() { if (objectnavigator.hasPrevious()) return objectnavigator.previous(); else return null; }
eb50f785-6aaa-47d8-9090-0f6f37f1e328
public void addObject(E obj) { objectlist.add(obj); }
13abfe41-4413-401d-bb96-9742ffd1e724
public String getFilename() { return filename; }
18bbb321-3683-4595-b750-0597f772411c
public void setFilename(String f) { filename = f; }
17c6489e-66b0-43d0-aed1-4721e4ebeb63
public Controller(){ scanner = new Scanner (System.in); goalFile = new File("goal.txt"); goal = new Goal(goalFile); gtfr = new TextFileRead(goalFile); }
c66a31fe-ecc3-4789-820e-8ac5fda8aa9a
public void displayUserPrompt() throws IOException{ //TODO check input for errors do { System.out.println("Please enter your username"); userName = scanner.nextLine(); } while(userName.length() < 0); this.loadActivities(); //load user's activities this.displayInitialPrompt(); //go to menu prompts }
a0e01f6f-d492-43bb-9a73-f9310fb1dace
public void displayInitialPrompt() throws IOException{ String response = null; do { System.out.println("What would you like to do?"); System.out.println("1) Create Goal"); System.out.println("2) View Goal"); System.out.println("3) Create Activity"); System.out.println("4) View Activities"); System.out.println("5) Quit"); response = scanner.nextLine(); if(response.equals("1")) this.displayCreateGoalPrompt(); else if (response.equals("2")) this.diplayGoals(); else if (response.equals("3")) this.displayCreateActivityPrompt(); else if (response.equals("4")) this.displayActivities(); else if (response.equals("99")) this.displayCreateSchedulePrompt(); //added for administrator creation of serialized schedules else this.ungracefulExit(); } while (!response.equals("5")); }
f084734d-e841-45e3-b1e5-295fe034a64b
public void diplayGoals(){ Goal[] g = goal.getGoal(); int ctr=0; while (g[ctr]!=null){ if(g[ctr].getUsername().equals(userName)){ System.out.println(g[ctr].toString()); System.out.println(ctr); } System.out.println("current user name is " + g[ctr].getUsername()); ctr++; } }
3d2e9e46-66f0-4179-8b20-3eb5b1b0ad5a
public void displayCreateGoalPrompt(){ System.out.println("Please enter goal type"); System.out.println("1) Marathon"); System.out.println("2) 10K"); System.out.println("3) 5K"); System.out.println("4) Spend more time on the couch"); { String goalType; int startdate; int enddate; String gt=null; goalType = scanner.nextLine(); if(!goalType.equals(4)){ if(goalType.equals("1")) gt="Marathon"; else if (goalType.equals("2")) gt="10K"; else if (goalType.equals("3")) gt="5K"; else { //HANDLE THE INCORRECT HERE!!! System.out.println("Incorrect Goal type"); } System.out.println("Please enter a start goal date in the form MMDDYYYY"); startdate = Integer.parseInt(scanner.nextLine().trim()); System.out.println("Please enter an end goal date in the form MMDDYYYY"); enddate = Integer.parseInt(scanner.nextLine().trim()); goal.setGoal(new Goal(userName, gt, startdate, enddate)); } } }
cebdbd44-d91a-46a6-98c5-5505f334002a
public Object displayCreateActivityPrompt() throws IOException{ Calendar cal = Calendar.getInstance(); Date date = cal.getTime(); //set to today Date duration = null; String title = ""; String note = ""; Activity activity = new Activity(userName); System.out.println("Record an activity"); //initial prompt title System.out.println("For today? Enter Y or N"); //default to today for usability String response = scanner.nextLine(); if(response.equals("Y") || response.equals("y") ) //get today's activity's duration { title = this.getTextInput("title"); if (title == null) return null; duration = this.getDuration(); note = this.getTextInput("note"); } else if (response.equals("N") || response.equals("n")) //get activity's date { System.out.println("Enter an activity for..."); System.out.println("(Y)esterday"); System.out.println("A date in MMDDYYYY format"); response = scanner.nextLine(); if (response.equals("Y") || response.equals("y")) { cal.add(Calendar.DAY_OF_MONTH, -1); date = cal.getTime(); title = this.getTextInput("title"); duration = this.getDuration(); note = this.getTextInput("note"); } } else { this.ungracefulExit(); } //set activity's user-entered parameters activity.setTitle(title); activity.setNote(note); activity.setDuration(duration); activity.setDate(date); //add activity to list this.activityList.addObject(activity); //save prompt not working as expected /*System.out.println("Save this activity now? Y/N"); response = scanner.nextLine(); if(response.equals("Y") || response.equals("y") ) { this.saveActivities(); }*/ return null; }
c0a1552a-cc8e-40ce-9eaa-2365e14a2bb6
private void displayActivities() { ListIterator<Activity> iterator = activityList.objectlist.listIterator(); do { System.out.println(iterator.next().toString()); } while(iterator.hasNext()); }
023f216a-0096-4fa3-83a4-b7745debb157
private void displayCreateSchedulePrompt() { // TODO Auto-generated method stub }
29f983c3-758f-4472-b2a6-9507e8f74cc0
private void loadActivities() throws IOException{ activityList.readObjectFile(userName); }
af069309-b9b3-4dd7-8e78-fb7e71cd7299
private void saveActivities() throws IOException{ activityList.writeObjectFile(); }
718c3ad3-2c7d-4741-9f5e-0c25cde15d94
private Date getDuration(){ Date dur = null; String response = null; do { response = this.getTextInput("duration as HHMMSS"); if(response != null) { try { dur = durationFormat.parse(response); } catch (ParseException e) { System.err.println("Input not in expected format"); } } }while (response == null && dur == null); return dur; }
327e23a5-d301-47ac-acbe-c731975fd7da
private String getTextInput(String param) { String response; System.out.println("Enter ".concat(param).concat(" or type P for previous menu")); response = scanner.nextLine(); if(response.equals("P") || response.equals("p")) { response = null; } return response; }
c44f29cd-c1a6-4a02-958a-4f5203141ff9
private void ungracefulExit() { System.out.println("Application now closing."); System.exit(0); }
d5365646-905e-4d05-b292-0d50cab126cf
public static void main(String[] args) throws IOException { //instantiate controller class Controller controller = new Controller(); controller.displayUserPrompt(); //give control to Controller for display of user prompts }
276caf47-8846-47fc-a3ce-8f709c6fed8b
public static void main(String[] args) { // TODO Auto-generated method stub LoadDriver.load(); }
f20f1d5f-3317-463c-8581-fe62016c8434
public static List<Event> load(){ Connection conn = null; Statement stat = null; ResultSet result = null; List<Event> list = new ArrayList<Event>(); try { Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/gent?user=root&password=root"); stat = conn.createStatement(); result = stat.executeQuery("select name, create_time, flag from event;"); while(result.next()){ Event evt = new Event(); evt.setName(result.getString("name")); evt.setFlag(result.getInt("flag")); evt.setCreateTime(result.getDate("create_time")); list.add(evt); } } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ if(result != null){ try { result.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } result = null; } if(stat != null){ try { stat.close(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } stat = null; } } return list; }
b974b071-7d39-4c8a-896a-417281f73f9c
public void Event(){ }
1614f54e-584d-4165-a558-5585d4145000
public void Event(String name, Date createTime, int flag){ this.name = name; this.createTime = createTime; this.flag = flag; }
afedcc56-9ab3-4860-84c8-c28200355f57
public String getName() { return name; }
fa9d89e5-c809-42de-9b84-bfd2bc5f54c4
public void setName(String name) { this.name = name; }
c64cfa95-3cd7-44e3-bee3-a40310ec96af
public Date getCreateTime() { return createTime; }
14e928e6-4715-45fc-a0a1-82bdabdbc856
public void setCreateTime(Date createTime) { this.createTime = createTime; }
dd8af283-fd1b-441d-862f-8d294bf4a7d0
public int getFlag() { return flag; }
b89b8d11-bac4-49a8-9e11-5acc6015b2c6
public void setFlag(int flag) { this.flag = flag; }
c434685b-d2af-4fcf-9a36-5a439ab84aa9
public String getLoveStart() { return loveStart; }
d8e5b082-040d-408b-b4fc-aaedbe0e675e
public void setLoveStart(String loveStart) { this.loveStart = loveStart; }
f0107784-9b42-4215-b7b1-b8e8b11645c9
public static void main(String[] args) { System.out.print("MyTest class is here."); Field[] fields = Event.class.getDeclaredFields(); System.out.println(fields.length); for(int i=0, len = fields.length; i < len; i++){ System.out.println(fields[i].getName()); } }
7d9e5d95-6ff6-481c-90ca-9abffba96b85
@Override public void destroy() { // TODO Auto-generated method stub }
ee7536de-f44a-455d-8484-647b04fbf7cd
@Override public ServletConfig getServletConfig() { // TODO Auto-generated method stub return null; }
d238485c-1e51-44da-bc06-b2381544bc1b
@Override public String getServletInfo() { // TODO Auto-generated method stub return null; }
e57b8423-bd47-4e9b-b2d5-c079ad65de86
@Override public void init(ServletConfig arg0) throws ServletException { // TODO Auto-generated method stub System.out.println("init"); }
436d98be-ad38-4bf6-8043-4f545d4a1f93
@Override public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException { // TODO Auto-generated method stub }
43053a1b-95cf-4dbc-b329-663ed61667e4
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // PrintWriter writer = resp.getWriter(); resp.setCharacterEncoding("utf-8"); List<Event> list = null; list = LoadDriver.load(); if(list == null && list.size() > 0){ writer.write("无事件相关数据。"); }else{ StringBuffer sb = new StringBuffer(); sb.append("{"); Field[] fields = Event.class.getDeclaredFields(); for(int j=0, size = list.size(); j < size; j++){ Event evt = list.get(j); for(int i=0, len = fields.length; i < len; i++){ String name = fields[i].getName(); sb.append("'"+ name +":'"); String str = name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase()) ; try { Method method = Event.class.getDeclaredMethod("get"+str, null); System.out.println(method.getName()); Object o = method.invoke(evt, null); if(o == null){ sb.append(""+ null +""); }else{ sb.append("'"+ o.toString() +"'"); } if((i+1)<len){ sb.append(","); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } sb.append("}"); writer.write(sb.toString()); } }
c87cd3d3-5d46-4e9c-9cc6-b1634e6546af
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub super.doPost(req, resp); }
76069df4-c2ed-4b1b-9488-c729cb6447e8
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // TODO Auto-generated method stub //super.doGet(req, resp); req.getRequestDispatcher("hello.jsp").forward(req, resp); //resp.sendRedirect("hello.jsp"); //resp.getWriter().write("using httpservlet interface"); }
59ff9fe2-fe6f-4b81-ab68-d0b189463d77
@Test public void ValidMidiChosen_ReadScore_Imported() { // Setup String testPath = "assets/midi/Hotel California.mid"; // Act Score result = MidiReader.readScore(testPath); // Assert assert (result != null); }
b4750af1-25a5-4101-ac82-e11f2ad74d5d
@Test public void FrameIsEmptyAndNoteExists_AddNote_FrameHasOneNote() { // Setup Note testNote = new Note(0, 0, 0, 0, 0, 0, 0); Frame testFrame = new Frame(0); int empty = testFrame.getNotes().size(); // Act testFrame.addNote(testNote); int result = testFrame.getNotes().size(); // Assert assert (empty == 0); assert (result == 1); }
ad1a24e1-d5aa-4519-972b-df983d60551e
@Test public void NoteExists_ChangePitch_NoteHasEnteredPitch() { // Setup Note testNote = new Note(0, 0, 60, 0, 0, 0, 0); int newPitch = 67; // Act testNote.setPitch(newPitch); // Assert assert (testNote.getPitch() == newPitch); }
c3953739-d0c8-4d8e-9dbd-516a5c887909
public Tablature getTablature() { return tabs; }
a108f29b-6bac-42cf-89c7-deaa29e6e3e9
@Override public void start(Stage primaryStage) { try { stage = primaryStage; stage.setTitle("IGTV"); stage.setMinWidth(MINIMUM_WINDOW_WIDTH); stage.setMinHeight(MINIMUM_WINDOW_HEIGHT); gotoImport(); primaryStage.show(); primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); } }); } catch (Exception e) { e.printStackTrace(); } }
033d7ffa-b81d-4627-bd20-da38489d0fbf
@Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); }
69e94d69-c932-4cc1-821e-18bbfe037897
public static void main(String[] args) { launch(args); }
cf085e5d-d9f0-4711-be99-5d44351f7897
public File requestMidiFile() { fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All Files", "*.*"), new FileChooser.ExtensionFilter("MIDI", "*.mid")); return fileChooser.showOpenDialog(stage); }