No message is printed if the two runs are of equal

This preview shows page 11 - 16 out of 16 pages.

No message is printed if the two runs are of equal speed. //5 marks if (run1.isFasterThan(run2)) System.out.println("Run "+run1.getRunID()+ " is faster"); else if(run2.isFasterThan(run1)) System.out.println("Run "+run2.getRunID()+ " is faster"); (15 marks)
Image of page 11

Subscribe to view the full document.

Candidate's Name:___________________ 12 COMPSCI 101 9. The Q9 application shown below creates a Q9Frame instance. import java.awt.*; public class Q9{ public static void main(String[] args){ Q9Frame theFrame = new Q9Frame("Question 9", 10, 20, 190, 200); } } Complete the Q9Frame class definition on the next page so that when the Q9 application is executed the following Frame is displayed. I have added some notes below the Frame to indicate the position of the line and shapes. The circle has a top left position at (40,100). The square has a top left position at (120,100). The circle has a radius of 15 pixels (diameter 30). The square is of size 30 pixels. The line between the circle and the square is 50 pixels long. The String “afer023” is at position (45,155); The String displayed inside the Frame should be your own upi (login name). The TextField contains the string “AMAZING”.
Image of page 12
Candidate's Name:___________________ 13 COMPSCI 101 import java.awt.*; import java.awt.event.*; public class Q9Frame extends Frame { private TextField theTextF; public Q9Frame(String title, int top, int left, int width, int height){ setTitle(title); setBounds(top,left, width, height); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ dispose(); System.exit(0); }}); setLayout(new FlowLayout()); //3 marks TextField theTextF = new TextField(" AMAZING "); add(theTextF); show(); } public void paint(Graphics g){ //6 marks g.drawOval(40,100,30,30); g.fillRect(120,100,30,30); g.drawLine(70,115,120,115); //Their upi in the drawstring() method g.drawString("afer023",45,155); } } (10 marks)
Image of page 13

Subscribe to view the full document.

Candidate's Name:___________________ 14 COMPSCI 101 Overflow Sheet Write the question number next to your answer. You must ALSO indicate in the allotted space that you have used the overflow sheet. _______________________
Image of page 14
COMPSCI 101 Rough Working You may remove this page from the exam script if you wish. This page will not be marked.
Image of page 15

Subscribe to view the full document.

COMPSCI 101 Rough Working You may remove this page from the exam script if you wish. This page will not be marked.
Image of page 16
You've reached the end of this preview.
  • Summer '12
  • AdrianaFerraro
  • Computer Science, Subroutine, Letter case, ASCII, kilometres

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern