Class Can't Implement Chart

Mar 10, 2014

i'm getting cryptic error messages for the following code:

class MyChar implements CharSequence{
private String s;

public MyChar(String input)
{
StringBuilder b = new StringBuilder(input);
b.reverse();
this.s = b.toString();

[code]....

it's telling me something's wrong with the class modifier and that my class can't implement chart

View Replies


ADVERTISEMENT

How To Implement A Variable Into Another Class

Apr 13, 2015

I would like to implement a variable in a class that is used in another class, how can I do that?

I have a Mall class and a Customer class I would like to associate the position of the customer that is in the Mall class and also implement the same in the Customer class.

Here is a small part of the code without all the methods.

//the two objects
Mall m = new Mall("RandomMall",50,30);
Customer c1= new Customer("Jack",1240);
//the first part of the mall class without the methods
class Mall{
private String name;
private int width,length;
String[][]grid = new String[width][length];

[code]...

View Replies View Related

ERROR When Try To Implement A Class

Dec 6, 2014

I'm writing a simple queue program using a netbeans as a GUI program I've used netbeans GUI editor to create the GUI my main problem was I've written the queuing code to a button function it works but it runs only once and the queue becomes empty on the second run. So I implemented a class which will create the queue outside the button click event but when I do that I get a Symbol not found: method error . The place where I get the error:

addStd1.setText("Add Student");
addStd1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addStd1ActionPerformed(evt);
}

My button function with the class:

class stdQueCls{
Queue stdQue;
public stdQueCls(){
stdQue = new LinkedList();
}
private void addStd1ActionPerformed(java.awt.event.ActionEvent evt) {

[code]....

View Replies View Related

How To Implement Own String Class

Feb 12, 2015

I am a beginner at Java programming. how to implement my own String class, but I have to provide my own implementation for the following methods:

public MyString1(char[ ] chars)
public char charAt(int index)
public int length( )
ublic MyString1 substring(int begin, int end)
public MyString1 toLowerCase( )

[code]....

I have looked through the API, but I don't really understand where to start.

View Replies View Related

How To Implement Class DynamicArrayStack

Feb 9, 2015

While learning how to implement the class DynamicArrayStack, I've run into some operators and syntax I'm unfamiliar with!

public class DynamicArrayStack{
protected int capacity
public static int MINCAPACITY=1<<15;
protected int[] stackRep;
protected int top = -1;
//initializes stack to use an array of default length
public DynamicArrayStack()
this(CAPACITY)

[code]....

View Replies View Related

How To Implement Interface And Extend Class

Apr 12, 2014

how to 'implement' an interface and 'extend' a class. Now I want to try and recall the information by memory without using any reference material.
Implementing an interface...

Java Code: //This interface will hold information for cell phones//Like saying... you can't BE a cell phone unless you have this information, at the very least

public interface CellInfo {
public void model();
public void make();
public void androidVer();

}

//Now I implement the interface for a class called Galaxy, which is a class about a specific phone

public class Galaxy implements CellInfo
public void model() {
System.out.println("I'm a Galaxy S5.");
}

public void make() {
System.out.println("I'm made by Samsung.");

[code]....

View Replies View Related

Implement Dialog Class For Leap Year

Apr 1, 2015

This assignment uses the following description to implement a Dialog class for the Leap Year Problem. We need to decompose this problem into 2 classes:

1.The Date.java class: is a public class that represents a date composed of a month , day, and a year. So you need to declare month, day, and year as integers. Date has 1 constructor and 4 methods. Write the constructor for Date which has 3 parameters: int m, int d, int y ; (As an example of a constructor with 2 parameters for example chapter 3 page 152 code listing 3-13 has a perfect example for you to use which is the BankAccount.java.) and the 4 methods:

"dayIs()" which returns a day. It has no parameter.
"monthIs()" which returns a month. It has no parameter.
"yearIs()" which returns a year. It has not parameter.
"isLeapYear()" which returns a boolean value.

"isLeapYear()" has one parameter year and returns a boolean. Write the method isLeapYear() knowing that a year is defined to be a leapyear it is a multiple of 4, and if it is is a multiple of 100, it must also be a multiple of 400. isLeapYear() thus decides when a year is a leap year. (see the discussion on "Hints for Assign5" to discover specific examples of a LeapYear).

The purpose of the Date.java is to decide whether a year is a leap year. Here is a definition of when a year is considered a leap year :

-year y1 is a leap year if it is multiple of 4.
-year y1 is a leap year if it is a multiple of 100, it must be a multiple of 400.
-Otherwise y1 is not a leap year.

2. The DateJDialog.java class: implements the GUI. Please use the Dialog boxes developed in the book in chapter2 in pages 99-100 in the code-listing 2-32 (NamesDialog.java) for input and output.

Remember that you will prompt the user to enter:
-a month;
-a day;
-a year

And out of these 3 you will be able to create a Date. Then you will use the dialog box to tell the user whether the year entered was a leapyear or not a leapyear.

Remember that we defined in 1- what it means a year is a leap year or not a leap year.

Do not forget to compile the 2 java files. To verify that the DateJDialog.java works, in TextPad after you compile DateJDialog.java, Click on Tools, Click on "Run Java Application".

When you have completed the assignment, please remember to submit Date.java and DateJDialog.java.

View Replies View Related

Java Interface - Implement Method In Another Class

Sep 17, 2014

So I created an interface which has the method

int getCalls();

I am trying to implement this method in another class but I'm not sure how to do so. My attempt is:

public getCalls(){ return getCalls(); }

When I run the program it sends the following exception:

Exception in thread "main" java.lang.StackOverflowError
at FibonacciForget.getCalls(FibonacciForget.java:14)
and it highlights the [return getCalls();] part.

What is the correct way to implement the getCalls() method?

View Replies View Related

Implement Class That Computes All Primes Up To Some Integer N

Feb 5, 2014

I am working on a problem that computes primes. Here is the problem: You are going to implement a class that computes all the primes up to some integer n. The technique you are to use was developed by a Greek named Eratosthenes who lived in the third century BC. The technique is known as the Sieve of Eratosthenes. The algorithm is described by the following pseudocode:

create a queue and fill it with the consecutive integers 2 through n inclusive.
create an empty queue to store primes.
do {
obtain the next prime p by removing the first value in the queue of numbers.
put p into the queue of primes.
go through the queue of numbers, eliminating numbers divisible by p.
} while (p < sqrt(n))
all remaining values in numbers queue are prime, so transfer them to primes queue

You are to use the Queue interface provided. When you want to construct a Queue object, you should make it of type LinkedQueue. These classes are included. You should define a class called Sieve with the following public methods:

Sieve() - Constructs a sieve object.

void computeTo(int n) - This is the method that should implement the sieve algorithm. All prime computations must be implemented using this algorithm. The method should compute all primes up to and including n. It should throw an IllegalArgumentException if n is less than 2.

void reportResults() - This method should report the primes to System.out. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method. It is okay for it to have an extra space at the end of each line.

int getMax() - This is a convenience method that will let the client find out the value of n that was used the last time computeTo was called. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method.

int getCount() - This method should return the number of primes that were found on the last call on computeTo. It should throw an IllegalStateException if no legal call has been made yet on the computeTo method.

Your reportResults method should print the maximum n used and should then show a list of the primes, 12 per line with a space after each prime. Notice that there is no guarantee that the number of primes will be a multiple of 12. The calls on reportResults must exactly reproduce the format of the sample log. The final line of output that appears in the log reporting the percentage of primes is generated by the main program, not by the call on reportResults.

Here is my class Sieve. I am having difficulty getting all the primes into the proper queue:

public class Sieve {
private Queue<Integer> primes;
private Queue<Integer> numList;
private boolean computed = false;
private int max;
private int count = 0;

[Code] ....

When I input say, 20, I only get 2, 3, and 11 back as primes. Somewhere in the algorithm (lines 40-54) I seem to have gone awry, but I'm not certain where. Here are the other classes:

SieveMain:
// This program computes all the prime numbers up to a given integer n. It uses the classic "Sieve of Eratosthenes" to do so.

import java.util.*;
public class SieveMain {
public static void main(String[] args) {
System.out.println("This program computes all prime numbers up to a");
System.out.println("maximum using the Sieve of Eratosthenes.");
System.out.println();

[Code] .....

View Replies View Related

Widget Class That Implement Comparable Interface

Mar 15, 2014

Below is the requirements and code. I am getting the error CODELAB ANALYSIS: LOGICAL ERROR(S)We think you might want to consider using: >

Hints:

-Correct solutions that use equals almost certainly also uses high
-Correct solutions that use equals almost certainly also uses low

Assume the existence of a Widget class that implements the Comparable interface and thus has a compareTo method that accepts an Object parameter and returns an int . Write an efficient static method , getWidgetMatch, that has two parameters . The first parameter is a reference to a Widget object . The second parameter is a potentially very large array of Widget objects that has been sorted in ascending order based on the Widget compareTo method . The getWidgetMatch searches for an element in the array that matches the first parameter on the basis of the equals method and returns true if found and false otherwise.

public static boolean getWidgetMatch(Widget a, Widget[] b){
int bot=0;
int top=b.length-1;
int x = 0;
int y=0;
while (bot >= top)

[code]....

View Replies View Related

Servlets :: How To Know Which Class Will Implement Which Session Listener Interface

Jan 23, 2015

how it is decided which class will implement a session listener interface? Which class will implement HttpSessionListener? Which one will implement HttpSessionActivationListener, HttpSessionBindingListener or HttpSessionAttributeListener?

View Replies View Related

How To Enforce Any Class Which Implements Interface Should Also Implement Comparable Too

Dec 15, 2014

How do you enforce any class which implements an interface should also implement comparable too? Say for instance you may have an interface

public interface Task
{ ... }
public class DoThis implements Task { ... }
public class DoThis1 implements Task { ... }

I want all of the classes which implements the interface Task to implement comparable too. Of course I can just say implements Task, Comparable. But is there something which we could do from interface level, i mean interface Task level?

View Replies View Related

Method That Return Instance Of A Class That Implement Iterator Interface

Apr 14, 2015

I have been researching the Iterator and making a class implement iterable. I have seen this example shown below and was wondering how I could change this so that iterable() is not called upon in the main. I would like to be able to make a method that returns an instance of a class that implements the Iterator interface hopefully an inner class. This is because my program will not have a main and will be supplied with a main that includes a new Object with will use the iterator method.

import java.util.*;
public class IteratorDemo {
public static void main(String args[]) {
// Create an array list
ArrayList al = new ArrayList();
// add elements to the array list
al.add("C");

[Code] ....

This is all I have been able to understand from what I want to do. This does not work and this is what I am trying to achieve

public class MyArrayList implements Iterable {
public static final int DEFAULT_SIZE = 5;
public static final int EXPANSION = 5;
private int capacity;
private int size;
private Object[] items;
 
[Code] ...

View Replies View Related

Implement Equality And HashCode Method If Class Has Reference Type Members?

Jan 16, 2015

I am trying to implement the following example to override the equality and hashCode method if the class has reference type member. I do get the expected result "true" for equal and "false" for non-equal objects. But the print statement in the Circle's equal method is not executed when the objects values are not equal. I don't know what i am missing, though i get the equality result "false" as expected for non equal objects.

class Point{
private int x, y;
Point (int x, int y) {
this.x =x;
this.y = y;

[code]....

View Replies View Related

Implement Functionalities Of Set Class Using A Private Data Member Of Type ListReferencedBased

Feb 9, 2015

Okay, I am supposed to implement the functionalities of the Set class using a private data member of type ListReferencedBased<E>,how the ListReferenceBased works with what I am trying to accomplish.I am trying to complete Set.java, and I have barely started and much of the code doesn't work. ListReferenceBased was given to me completed.

import java.util.Iterator;
pubic class ListReferenceBased<E> implements ListInterface<E>, Iterable<E>{
/** reference to the first element of the list */
private Node<E> head;
/** number of items in list */
private int numItems;

[code]....

View Replies View Related

Swing/AWT/SWT :: Error At Class Name - Type JTextField Must Implement Inherited Abstract Method

Oct 27, 2014

This code is directly from Swing: I'm using Eclipse and keep getting an error on line 10 saying :

"The type JTextField must implement the inherited abstract method ActionListener.actionPerformed(ActionEvent)."

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

[Code] ......

View Replies View Related

How To Create A PIE Chart

Jan 14, 2014

Here is the application that does this; test your coding of class PieChartWriter with it.

import java.awt.*;
public class TestPieChart
{ public static void main(String[] args)
{ PieChartWriter p = new PieChartWriter();
p.setTitle("How I spend my day");
p.setSlice1("Sleep: 7 hours", 7, Color.black);
p.setSlice4("Recreation: 9 hours", 9, Color.gray);
p.setSlice2("In class: 3 hours", 3, Color.blue);
p.setSlice3("Homework: 5 hours", 5, Color.red);
}
}

View Replies View Related

Bar Chart With Asterisks

Oct 12, 2014

I need to make a loop that prints out a certain number of asterisks, depending on the random number generated (includes 0-24, not including 25). I'm just in basic java programming and am stuck on this task.

These are the directions given to me:

Write a loop to do the following tasks 10 times:
-Generate a random number in the range of 0 to 24 and store in an int variable named: score
-Write loop to print a bar of asterisks proportional to the value in score :

For example: , if value stored in score is 8, the bar chart should like as follows: (value of score spaced by a tab ( ) and a series of 8 asterisks in one line)
8 ********
//end of the loop

I've tried looking for other questions like this, but this one is a random number, with no input. Yes, I know there are easier ways, but my professor is extremely picky with everything.

This is what I have so far:

public class PA5LoopsA {
public static void main(String [] args) {
//Declare variables
int score;
//Generate random number between 0 and 24
score = (int) (Math.random() * 25);

[Code] ....

Clearly, none of my formatting went through...yes, I know how to space everything out!

View Replies View Related

Bar Chart With Asterisks?

Oct 19, 2014

Here is the assignment instructions:

Overview: Use the Eclipse Java environment to create and test a program using methods that will display a bar graph.

Specifics: This assignment is an extension of the Module 5 activity, the first bar chart (asterisk) display program. You should also make use of the Bar Chart printing program of Chapter 6 (Fig. 6 in the textbook, p. 217).

Your program should use methods to accept input from the keyboard, store it in an array, and use that data to display a bar graph.

Pseudocode for the program might look like the following.

Main
declare an array of integers
get the number of asterisks in each bar
print the bar graph
get the number of asterisks in each bar
declare a Scanner input object
declare an array to fill and return

[code]....

Problem is I cannot get it to display the number of asterisks I enter as input.

View Replies View Related

Creating A Chart For Work?

Mar 6, 2015

I need to create a chart for work and comes across this sample from mbostock's chord diagram (bl.ocks.org/mbostock/4062006).

I only need to revise the tick label (names, display positions) but I don't know how to do it as I have 0 experience with Java.

My sample data for the var matrix is

[0,100,100,100]
[0,0,99,98]
[0,0,92,84]
[0,99,0,0]

which shows flows between country A, B, C and D.

I would like to revise the tick labels, so that:

1) Instead of showing 0K 5K 10K, I would like to show the country names (A - D), with no number or tick. I figured out this one by just commenting out all the codes relating to ticks.

2) Place the country names in the center of the arch. I don't know how to do this one.

View Replies View Related

JSF :: Organizational Chart In Primefaces

Dec 31, 2013

I would like to create this type of chart with Primefaces (or another JSF API), what is the best component to use to do this:

[URL] .....

View Replies View Related

Displaying Pie Chart In JScrollPane

Mar 12, 2014

I have a JScrollPane and JTable inside. In the right column of the table at the end (south) I made a ChartPanel in one of the classes where I make the design for the Frame:

Java Code:

ChartPanel chartpanel = new ChartPanel(pieChart);
pCapturing.add(chartpanel, BorderLayout.NORTH); mh_sh_highlight_all('java');

And when I click on any row above, from the list in the column, I would like an appropriate pie chart to be drawn.

I need here (in another class where I define the getTableCellRendererComponent) to enter a code to display the chart in the last row of the panel:

Java Code:

PieChart3 pie=sectionsChartProvider.getSectionPieChart(section);
...
...
if((hasFocus) || (isSelected)) {
if(column == 0)
setBorder( new MatteBorder(1, 1, 1, 0, colorBorder) );

[Code] .....

But, I don't know how to do this. I also have a class for drawing the pie chart.

View Replies View Related

Making Pie Chart For Values That The Row Contain

Mar 9, 2014

I use JTable and JScrollpane in my java application, and I would like for every selected row in the scroll pane, the pie chart to be made for the values in % that the row contain.

View Replies View Related

Seating Plan / Chart

Sep 15, 2014

I want to develop a seating chart/plan where people can pick their seat etc. I have developed the UML diagrams etc for this project and want to start with a console version before developing a GUI version. Eventually I want to create a website where users can log in and reserve their seats etc.

Without sounding like I'm putting the cart before the horse, I want to know what Java technologies I will need to develop the final part of the project. At the moment I'm using Eclipse for getting through the Java text books.

View Replies View Related

Administrative Chart Plotting

Feb 18, 2015

I want to plot an administrative chart(flow chart of an organization) and I truly do not not know how to start.

* Collect data from database
* use jgraph or any other api to create the flow chart.

View Replies View Related

Print Array Asterisk Bar Chart

Jul 6, 2014

I am trying to get this program to take 5 integers from a user and print a bar chart made of asterisks. The only way I've been able to access the values stored in the array is when my loops are nested, but this keeps my output from printing the way I would like it to.

It prints:
Enter a number:
2
**
Enter a number...and so on

I want it to take the values say(2,3,5,8,4) and do this:
**
***
*****
********
****

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int[] barArray = new int[5];
for(int i =0; i < barArray.length; i++){
System.out.println("Enter a number: ");
barArray[i] = in.nextInt();
for(int j = 0; j < barArray[i]; j++){
System.out.print("* ");
}System.out.println("");
in.close();
}
}

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved