1 / 5

Recitation 3

Recitation 3.

Download Presentation

Recitation 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Recitation 3 In this assignment you will write a program to pick up the uppercase letters in an input string. It is pretty much like the program in the lecture, but this time it should be implemented as a bean class that implements an interface. And you also need to use ObjectEditor to enter the input string and to get the uppercase string, which is a string consisting of all of the upper case letters in the input string.

  2. The code of the main method is provided. So you need to name the class and interface accordingly (class name: AnUppercaseFilter. Interface name: UppercaseFilter). Also note the import statement and “ObjectEditor.edit(filter)”. Later you will need the code to use ObjectEditor in homework. import bus.uigen.ObjectEditor; public class Driver { public static void main(String[] args){ UppercaseFilter filter = new AnUppercaseFilter(); filter.setString("Initial Input"); ObjectEditor.edit(filter); } }

  3. To follow the bean pattern, you should have two string properties, one for the input string and another for the uppercase letters string. You also need two getter methods for each of the properties. Since the input string is the user specified variable while the uppercase letter string is not, you should only have one setter method, which is for the input string. You can either put the code for picking up in the getter method or in a separated method.

  4. To let the ObjectEditor recognize the bean class, you need to add annotations above the header of the class. The annotations are: importutil.annotations.StructurePattern; importutil.annotations.StructurePatternNames; @StructurePattern("Bean Pattern") The purpose of these annotations is to let the ObjectEditor know what type of the object is , and display the object according to its type. In future homework you will use annotations to draw rectangles and lines on ObjectEditor.

  5. Bean Pattern: http://cs.unc.edu/~dewan/comp401/current/Lectures/StateProperties.pptx Interface: http://cs.unc.edu/~dewan/comp401/current/Lectures/Interfaces.pptx Annotations: http://cs.unc.edu/~dewan/comp401/current/Lectures/DocumentationAnnotations.pptx It is helpful to review the code of BMICalculator, which is in these two slides.

More Related