Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

lease Provide me all necssary Screenshort and Commentds:(I use eclipse) Requirements For this program you will be asked to write a simple data management program.

lease Provide me all necssary Screenshort and Commentds:(I use eclipse)

Requirements

For this program you will be asked to write a simple data management program. Start by choosing what sort of thing you would like to keep track of. For example,

Student information

Vacation or travel information

Information about courses

Plants

Pets

Food

Your program will manage your data collection. We will start with the simplest collection of data, a list. Your list will contain the Things of your choice.

Requirements for YourChoiceOfThing Class

Implement the sort of Thing to be stored as a class. The object/class must have the following characteristics:

At least 5 attributes/characteristics

At least one numeric attribute

At least one String attribute

One String attribute should be usable as a search key (for example, the name of a Food item)

Implement getters and setters for all the attributes of your Thing of choice.

Implement an equals() method for your Thing class.

Requirements for the CollectionOfYourThings Class

Create a collection of Things using an array. You may NOT use the library classes ArrayList or Vector.

Implement a constructor which accepts as an argument the maximum size of the data collection.

Implement a search method which returns a single object.

Implement an add, update, delete methods.

User Interface Class

Use the user interface class provided for you in class. A soft copy is available for download from D2L.

Alter the user interface class to use YOUR classes. Change the names of the classes to reflect your item of interest.

Allow the user to:

Enter data and store it in the list.

Update an entry in the list

Delete an entry from the list

Search for an item in the list.

Duplicates should not be allowed.

Display the complete list. The list which is displayed should accurately reflect the items stored in the data structure. That is, if an item is updated or deleted, the list which is displayed should show that.

Given a search key by the user, search your list for a matching object. Retrieve and display all information for the matching object. The search key should be CASE INSENSITIVE. For example, ITEM should be a match for item or IteM. Your search key must be a string, not a number.

Display the number of items in the list.

Use of a graphical user interface such as swing is required.

Grading Criteria

Methods must be of appropriate length usually less than 1 page in length

Appropriate private and public access modifiers must be used. Almost always data is private and methods are public although you may certainly have private or protected methods if appropriate.

User interface is intuitive and easy to use.

Meets program specifications as described above

The program is robust with no runtime errors or problems

Program is readable

Comments

Use Javadocs conventions (Appendix H)

Include comments on the class as a whole including

Description of program

Your name (use @author)

Date (due or date you started or last modified)

Source of any borrowed code

For each method include

Concise description of what method does

Arguments for each method (use @param)

Returned value (use @returns)

Exceptions which are thrown (@throws)

Consistent and correct indenting

Meaningful identifiers

Normal capitalization conventions are used

The source of any "borrowed" code is clearly identified

-----------------------------------------------------------------------------------------------

Item.java

public class Item {

private String data1;

public String getData1() {

return (data1);

}

public void setData1(String data1) {

this.data1 = data1;

}

public String toString() {

String s;

s = "Data1 = \"" + data1 + "\"";

return (s);

}

}

------------------------------------------------------------------------------------------------------

Project1Applet.java

// This applet is a small example to illustrate how to write an interactive

// Applet to test the methods of another class.

// -- Michael Main (main@colorado.edu)

// -- Robin Ehrlich (Robin.Ehrlich@metrostate.edu)

import java.applet.Applet;

import java.awt.*; // Imports Button, Canvas, TextArea, TextField

import java.awt.event.*; // Imports ActionEvent, ActionListener

import java.util.Iterator;

public class Project1Applet extends Applet

{

private static final long serialVersionUID = 1L;

private ArrayBag b = new ArrayBag( );

// These are the interactive Components that will appear in the Applet.

// We declare one Button for each ArrayBag method that we want to be able to

// test. If the method has argument(s), then there is also TextField(s)

// where the user can enter the value of the argument.

// At the bottom, there is a TextArea to write messages.

private Button addButton = new Button("add");

private Button updateButton = new Button("update");

private Button deleteButton = new Button("delete");

private Label elementLabel1 = new Label("Element 1");

private TextField elementText1 = new TextField(20);

private Label elementLabel2 = new Label("Element 2");

private TextField elementText2 = new TextField(20);

private Label elementLabel3 = new Label("Element 3");

private TextField elementText3 = new TextField(20);

private Label elementLabel4 = new Label("Element 4");

private TextField elementText4 = new TextField(20);

private Label elementLabel5 = new Label("Element 5");

private TextField elementText5 = new TextField(20);

private Button searchButton = new Button("search");

private TextField targetText = new TextField(20);

private Button listAllButton = new Button("list all");

private Button sizeButton = new Button("size");

private TextArea feedback = new TextArea(7, 80);

public void init( )

{

// size window to contain all fields

resize(600, 500);

// set a useful window title

Frame frame = (Frame) this.getParent().getParent();

frame.setTitle("ICS 240 - Project 1 - ");

// remove unneeded menu

frame.setMenuBar(null);

add(new Label("This test program has created a bag."));

add(new Label("Press buttons to activate the bag's methods."));

addHorizontalLine(Color.blue);

// The Button and TextFields for testing the add, update and delete methods

add(elementLabel1);

add(elementText1);

addNewLine( );

add(elementLabel2);

add(elementText2);

addNewLine( );

add(elementLabel3);

add(elementText3);

addNewLine( );

add(elementLabel4);

add(elementText4);

addNewLine( );

add(elementLabel5);

add(elementText5);

addNewLine( );

add(addButton);

add(updateButton);

add(deleteButton);

addHorizontalLine(Color.blue);

// The Button and TextField for testing the search method:

add(searchButton);

add(targetText);

addHorizontalLine(Color.blue);

// The Button for testing the list and size method

add(listAllButton);

add(sizeButton);

addNewLine( );

// A TextArea at the bottom to write messages:

addHorizontalLine(Color.blue);

addNewLine( );

feedback.setEditable(false);

feedback.append("Ready for your first action. ");

add(feedback);

// Tell the Buttons what they should do when they are clicked:

addButton.addActionListener(new AddListener( ));

updateButton.addActionListener(new UpdateListener( ));

deleteButton.addActionListener(new DeleteListener( ));

searchButton.addActionListener(new SearchListener( ));

sizeButton.addActionListener(new SizeListener( ));

listAllButton.addActionListener(new ListAllListener( ));

}

class ListAllListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

int i;

ArrayBag.ItemIterator it;

Item item;

it = b.iterator();

i = 1;

while(it.hasNext()) {

item = it.next();

feedback.append(i + ": " + item.toString() + " ");

i += 1;

}

showStatus("List All action completed");

}

}

class SizeListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

feedback.append("The bag has size " + b.size( ) + ". ");

showStatus("Size action completed");

}

}

class AddListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

try

{

String userInput1 = elementText1.getText( );

String userInput2 = elementText2.getText();

String userInput3 = elementText3.getText();

String userInput4 = elementText4.getText();

String userInput5 = elementText5.getText();

// TODO - validate and do something with all of inputs

b.add(userInput1);

feedback.append(userInput1 + " has been added to the bag. ");

showStatus("Add action completed");

}

catch (NumberFormatException e)

{

feedback.append("Type an integer before clicking button. ");

elementText1.requestFocus( );

elementText1.selectAll( );

}

}

}

class UpdateListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

try

{

showStatus("Update action not yet implemented");

}

catch (NumberFormatException e)

{

feedback.append("Type an integer before clicking button. ");

elementText1.requestFocus( );

elementText1.selectAll( );

}

}

}

class DeleteListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

try

{

showStatus("Delete action not yet implemented");

}

catch (NumberFormatException e)

{

feedback.append("Type an integer before clicking button. ");

elementText1.requestFocus( );

elementText1.selectAll( );

}

}

}

class SearchListener implements ActionListener

{

public void actionPerformed(ActionEvent event)

{

try

{

String userInput = targetText.getText( );

// TODO - do something with the input

// display Item value

showStatus("Search action not yet implemented");

}

catch (NumberFormatException e)

{

feedback.append("Type a target before clicking button. ");

targetText.requestFocus( );

targetText.selectAll( );

}

}

}

private void addHorizontalLine(Color c)

{

// Add a Canvas 10000 pixels wide but only 1 pixel high, which acts as

// a horizontal line to separate one group of components from the next.

Canvas line = new Canvas( );

line.setSize(10000, 1);

line.setBackground(c);

add(line);

}

private void addNewLine( )

{

// Add a horizontal line in the background color. The line itself is

// invisible, but it serves to force the next Component onto a new line.

addHorizontalLine(getBackground());

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

3rd Edition

0128012757, 978-0128012758

More Books

Students also viewed these Databases questions

Question

3. Explain the forces that influence how people handle conflict

Answered: 1 week ago