Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

Similar documents
Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Object-Oriented Software Engineering Re-exam, 2012 (Also Object-Oriented Analysis, Design and Programming, Re-exam, 2012)

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

This exam is closed textbook(s) and closed notes. Use of any electronic device (e.g., for computing and/or communicating) is NOT permitted.

Midterm assessment - MAKEUP Fall 2010

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

MIT AITI Swing Event Model Lecture 17

CSCI 201L Midterm Written Summer % of course grade

SampleApp.java. Page 1

The JFrame Class Frame Windows GRAPHICAL USER INTERFACES. Five steps to displaying a frame: 1) Construct an object of the JFrame class

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

G51PGP Programming Paradigms. Lecture 009 Concurrency, exceptions

Graphical User Interface

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2012

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Name: Checked: Learn about listeners, events, and simple animation for interactive graphical user interfaces.

COMP16121 Sample Code Lecture 1

Building a GUI in Java with Swing. CITS1001 extension notes Rachel Cardell-Oliver

Object-Oriented Software Engineering (Re-exam for Object-Oriented Analysis, Design and Programming)

G51PGP Programming Paradigms. Lecture 008 Inner classes, anonymous classes, Swing worker thread

Final Exam CS 251, Intermediate Programming December 13, 2017

CSCI 201L Midterm Written SOLUTION Summer % of course grade

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

RAIK 183H Examination 2 Solution. November 11, 2013

AP CS Unit 11: Graphics and Events

SINGLE EVENT HANDLING

CMP 326 Midterm Fall 2015

Java Interfaces Part 1 - Events Version 1.1

Agenda. Container and Component

RAIK 183H Examination 2 Solution. November 10, 2014

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Window Interfaces Using Swing Objects

Overview. Lecture 7: Inheritance and GUIs. Inheritance. Example 9/30/2008

Frames, GUI and events. Introduction to Swing Structure of Frame based applications Graphical User Interface (GUI) Events and event handling

Answer on question #61311, Programming & Computer Science / Java

Swing I CHAPTER EVENT-DRIVEN PROGRAMMING 921 Events and Listeners 921

Swing I Event-Driven Programming Buttons, Events, and Other Swing Basics Containers and Layout Managers 946

Multimedia Programming

CSCI 136 Written Exam #2 Fundamentals of Computer Science II Spring 2015

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

CSIS 10A Assignment 7 SOLUTIONS

GUI Forms and Events, Part II

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

EXAMINATION FOR THE BSC (HONS) INFORMATION TECHNOLOGY; BSC (HONS) INFORMATION SYSTEMS & BSC (HONS) COMPUTER SCIENCE; YEAR 1

Graphics User Defined Forms, Part I

Chapter 4 Defining Classes I

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Example: Building a Java GUI

Example: Building a Java GUI

B2.52-R3: INTRODUCTION TO OBJECT ORIENTATED PROGRAMMING THROUGH JAVA

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

Queen s University Faculty of Arts and Science School of Computing CISC 124 Final Examination December 2004 Instructor: M. Lamb

PART1: Choose the correct answer and write it on the answer sheet:

Graphical User Interfaces in Java - SWING

Control Flow: Overview CSE3461. An Example of Sequential Control. Control Flow: Revisited. Control Flow Paradigms: Reacting to the User

CS 180 Final Exam Review 12/(11, 12)/08

CS 209 Spring, 2006 Lab 8: GUI Development Instructor: J.G. Neal

Midterm Test II Object Oriented Programming in Java Computer Science, University of Windsor Fall 2014 Time 2 hours. Answer all questions

Introduction to the JAVA UI classes Advanced HCI IAT351

Window Interfaces Using Swing Objects

Points Missed on Page page 1 of 8

APPENDIX. public void cekroot() { System.out.println("nilai root : "+root.data); }

Class 16: The Swing Event Model

CS Exam 3 - Spring 2010

SE1021 Exam 2. When returning your exam, place your note-sheet on top. Page 1: This cover. Page 2 (Multiple choice): 10pts

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

Parts of a Contract. Contract Example. Interface as a Contract. Wednesday, January 30, 13. Postcondition. Preconditions.

PIC 20A GUI with swing

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

Java, Swing, and Eclipse: The Calculator Lab.

User interfaces and Swing

Programming Languages and Techniques (CIS120)

Abstract class & Interface

JRadioButton account_type_radio_button2 = new JRadioButton("Current"); ButtonGroup account_type_button_group = new ButtonGroup();

Object Oriented Programming is a programming method that combines: Advantage of Object Oriented Programming

CSC207 Week 4. Larry Zhang

C08: Inheritance and Polymorphism

CS Exam 1 Review Suggestions

We are on the GUI fast track path

DEMYSTIFYING PROGRAMMING: CHAPTER SIX METHODS (TOC DETAILED) CHAPTER SIX: METHODS 1

Inheritance. Chapter 7. Chapter 7 1

GUI Applications. Let s start with a simple Swing application in Java, and then we will look at the same application in Jython. See Listing 16-1.

Introduction. Introduction

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

Java Programming Lecture 6

Java Never Ends MULTITHREADING 958 Example: A Nonresponsive GUI 959

Software and Programming 1

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

CS180 Spring 2010 Exam 2 Solutions, 29 March, 2010 Prof. Chris Clifton

DCS235 Software Engineering Exercise Sheet 2: Introducing GUI Programming

Transcription:

Systems Programming Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid Leganés, 21st of March, 2014. Duration: 75 min. Full name:........................................................................ Signature:......................................................................... Instructions All the problems contribute the same to the final score. You are only allowed a black or blue pen (or two), a clock or a watch and the DNI or the Student Identification Card. This means: no pencils, phones, calculators.... Ignore this line:.,..,,., Problem 1 Write a Java Counter application that counts clicks on a button and resets the count by clicking on another button. The visual appearance and behavior of the application is shown in the figure in the next page. 1

Initial status After 5 clicks to the Increment button 28 clicks after the the clear You must take into account the following restrictions: After one or more clicks to the Clear button The visual appearance of your application must be like the one shown in the figure. Your solution must compile and run using the following invocations: ; javac Counter.java ; java Counter Your must solve the problem using only one class. Such class must inherit from JFrame and implement ActionListener and you must take maximum advantage of these two properties. This means you must not invoke new JFrame(...) on your code and you must not instantiate any new objects as listeners for the buttons. Points will be awarded for code clarity and readability (20% of the final score). Answer this problem by filling out the box in the next page. 2

3

Problem 2 Consider PurchaseItem, a parent class which models customer s purchases. This class must have, at least: Two private instance variables name (String) and unitprice (double) (i.e. price per unit of the product). One constructor to initialize the instance variables. A public abstract getprice() method. Override public String tostring() method to return the name of the item followed by an @ symbol, then the unitprice. Consider CountedItem, a subclass with an additional private variable quantity of type int. Write an appropriate constructor for the CountedItem class. Implement the getprice method of the purchased item based on its unit price and its quantity. Override the tostring method to add the x symbol, the quantity, a = symbol and the final price to the original output string. Also write a Test class that prints to the standard output a purchase of 2 apples, with a unit cost of 3.25 Euros. The result of executing this test class should be: ; java Test Apple@3.25x2=6.5 Code simplicity through reusability will be rewarded, so keep the public API of your classes simple and short. Answer this problem by filling out the three boxes in the next page (one for each class). 4

5

Answer to problem 1 import java.awt.borderlayout; import java.awt.event.actionevent; import java.awt.event.actionlistener; import javax.swing.jbutton; import javax.swing.jframe; import javax.swing.jlabel; import javax.swing.swingconstants; public class Counter extends JFrame implements ActionListener { private JLabel display; private int counter; public Counter() { super("counter"); counter = 0; setdefaultcloseoperation(jframe.exit_on_close); JButton increment = new JButton("Increment"); increment.addactionlistener(this); JButton clear = new JButton("Clear"); clear.addactionlistener(this); display = new JLabel(Integer.toString(counter), SwingConstants.CENTER); add(display, BorderLayout.NORTH); add(increment, BorderLayout.CENTER); add(clear, BorderLayout.SOUTH); pack(); setvisible(true); @Override public void actionperformed(actionevent e) { if (e.getactioncommand().equals("increment")) { counter++; else { counter=0; display.settext(integer.tostring(counter)); public static void main(string[] args) { javax.swing.swingutilities.invokelater(new Runnable() { public void run() { Counter gui = new Counter(); ); 6

Evaluation criteria for problem 1 The problem is graded from 0 to 10, being 0 the lowest mark and 10 the highest. The student mark starts at 0, then the following modifiers are applyed in order: [C100] (+1) (may be applyed twice) Code clarity and readability. Subjective. [C102] (+1) The application GUI is visualy correct. [C103] (+1) Correct class attributes and its initialization (display and counter). [C104] (+1) Correct inheritance from JFrame and use of super in the constructor. [C105] (+1) Correct implementation of the ActionListener interface. [C106] (+1) ActionListener (this) is added to buttons. [C107] (+1) Correct int to string conversion (counter to label). [C108] (+1) Correct handling of the two ActionEvent sources (including String comparison). [C109] (+1) Correct JLabel update on the actionperformed method. [C110] (-1) (may be applyed several times) Subjective penalty. Don t consider errors related with the thread safety of SWING objects, as the students don t have enought theorical background on this topic. 7

Answer to problem 2 public abstract class PurchaseItem { private String name; private double unitprice; public PurchaseItem(String name, double unitprice) { this.name = name; this.unitprice = unitprice; public abstract double getprice(); public double getunitprice() { return unitprice; @Override public String tostring() { return name + @ + unitprice; public class CountedItem extends PurchaseItem { private int quantity; public CountedItem(String name, double unitprice, int quantity) { super(name, unitprice); this.quantity = quantity; @Override public double getprice() { return getunitprice() * quantity; @Override public String tostring() { return super.tostring() + x + quantity + = + getprice(); public class Test { public static void main(string args[]) { System.out.println(new CountedItem("Apple", 3.25, 2)); 8

Evaluation criteria for problem 2 The problem is graded from 0 to 10, being 0 the lowest mark and 10 the highest. The student mark starts at 0, then the following modifiers are applyed in order: [C200] (+1) Correct attributes of the PurchaseItem class [C201] (+1) Correct constructor of the PurchaseItem class [C202] (+1) Correct getprice() of the PurchaseItem class [C203] (+1) Correct getunitprice() of the PurchaseItem class [C204] (+1) Correct tostring() of the PurchaseItem class [C205] (+1) Correct attributes of the CountedItem class [C206] (+1) Correct constructor of the CountedItem class [C207] (+1) Correct getprice() of the CountedItem class [C208] (+1) Correct tostring() of the CountedItem class [C209] (+1) Correct Test class [C210] (-5) CountedItem do not extends from PurchaseItem [C211] (-1) (may be applyed several times) Subjective penalty. Pay special attention to lack of code reusability or the existence of extra public methods not really needed. A cascade of errors must count as the sum of all of them, for example, declaring the attributes public and failling to provide a getunitprice() will count as [C200] and [C203]. 9