


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An assignment for a java programming course where students are required to write a class that defines two properties: input (a string) and tokenarray (a string array). The input property is editable, while tokenarray is a computed property that stores words and numbers found in the input string. Students are expected to use character.isdigit(), character.isletter(), substring(), length(), and charat() functions for this assignment. The document also provides instructions for testing the class using two main programs and objecteditor.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!
In this assignment, you will get more practice scanning. In addition, you will learn instance variables, properties and class instantiation. This work will build on your previous assignment.
Task Write a class that defines two properties: (1) Input of type String, and (2) TokenArray , of type String[]. You can assume a maximum size , MAX_TOKENS, for TokenArrray. Input is an editable property and TokenArray is a readonly computed property. Input is expected to contain digit sequences (numbers) and letter sequences (words). You can assume that there:
Your task is to scan Input for the words and numbers and store them in TokenArray. More specifically, if you find N words and numbers in the string, then you should store them in the first N slots of the array. 1. You should not convert a digit sequence into a number for this assignment – you should store it directly as a string.
You should write two main programs to test this class. One takes a string argument, prints it, and then uses an instance of this class to set Input and then print all the elements of TokenArray. The other takes no string argument, and user ObjectEditor to interact with an instance of the class. The following screen shots from ObjectEditor illustrate the interaction with the object.
(a) Initial Display (b) User edits Input and presses Enter
(c) User Re‐edits and presses Enter
Figure 1 ObjectEditor Interaction
There are two parts to this assignment. The first is to recognize words in addition to numbers. The second is put the scanner code into a class with the two properties. It may be best to do the assignment in two parts. First, change the last assignment to recognize and print words and numbers. Next, create an instantiatable class with the required properties. Let me know ASAP if ObjectEditor creates problems – that is does not display or set a property value correctly.
Your displays might not be identical to the ones I show in the assignment handout even when you use the same examples. The difference may be caused by different versions of ObjectEditor (I am using the latest version) and initial values. The displays and initial values do not matter, anything is acceptable. What matters is that you implement and update the properties correctly.
program, and interaction with ObjectEditor for the second main program. To print a window, do the following. Click on a window and then press Alt and PrtSc keys together. This will copy the image to a buffer. You can now paste the buffer in a document.
Good luck!