Method GetRadius In Class Circle Cannot Be Applied To Given Types
Sep 15, 2014
I am getting an error with my code. How to fix it.
import java.util.Scanner;
import java.util.*;
/*
* FileName: Circle.java
*/
public class Circle {
private double PI = 3.14159;
private double radius;
public Circle()
{
radius = 0.0;
[Code] ....
This is the error i am receiving:
Circle.java:78: error: method getRadius in class Circle cannot be applied to given types;
System.out.println("A circle with a radius of " + circle.getRadius() + " will have an area of " + circle.getArea() + " , a diameter of " + circle.getDiameter() + " and a circumference of " + circle.getCircumference());
^
required: double
found: no arguments
reason: actual and formal argument lists differ in length
1 error
View Replies
ADVERTISEMENT
Sep 7, 2014
I'm new to programming and I have an assignment due in java class. Here is the error code:
TestCircle.java:10: error: method setradius in class Circle cannot be applied to given types;
circle1 = inputCircle.setradius();
^
required: double
found: no arguments
reason: actual and formal argument lists differ in length
And here is my code:
import java.util.Scanner;
public class TestCircle
{
public static void main(String[] args)
{
double circle1;
double circle2;
double circle3;
Circle inputCircle = new Circle();
[Code] ......
View Replies
View Related
Sep 23, 2014
Here is my code:
import java.util.*;public class DebugSix {
public static void main(String[] args) {
ArrayList<String>products = new ArrayList();
products.add("shampoo");
products.add("moisturizer");
products.add("conditioner");
Collections.sort(products);
[Code] ....
I am using netbeans and getting errors for display(); and size(); it is telling me the errors are :
for the display error, "method display in class DebugSix cannot be applied to given types;
display();" and for the size() is : "cannot find symbol System.out.println("
The size of the list is " + size());"
View Replies
View Related
Feb 13, 2015
This code works
public class RedShapeDecorator extends ShapeDecorator {
public RedShapeDecorator(Shape decoratedShape) {
super(decoratedShape);
}
Below results in an error
public class RedShapeDecorator extends ShapeDecorator {
protected Shape decoratedShape;
public RedShapeDecorator(Shape decoratedShape) {
this. decoratedShape=decoratedShape;
}
So I am guessing that if you extend class, you should use super to pass objects?
View Replies
View Related
Apr 21, 2015
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package BaiVeNha;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.DefaultTableModel;
[Code] ....
View Replies
View Related
Aug 1, 2014
So i declared a class in main class but it seems there's error when i compile:
constructor xx in class xx cannot applied to given types
This is my java class:
public class trainer extends person{
String classType;
public trainer(String name, String gender, String address, int id, String classType) {
super(name,gender,address,id);
this.classType=classType;
[Code] ....
And this is the way i declared in main class:
trainer tr = new trainer();
And what i want to do is:
tr.toString();
View Replies
View Related
Jun 12, 2014
I'm getting an error on line 51 and don't know what it means?
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package million;
import java.util.Scanner;
import java.util.ArrayList;
[code].....
View Replies
View Related
Jun 22, 2014
So I have this line of code...
ioexception11.addChoosableFileFilter(new Jframe());
And when I compile it gives me...
error: constructor Jframe in class Jframe cannot be applied to given types;
ioexception11.addChoosableFileFilter(new Jframe());
View Replies
View Related
Jan 21, 2014
I'm doing an exercise we're you're supposed to sort strings in alphabetical order, without importing anything , not using the Arrays.sort() method.
I think I got the method down partially right, or it is on the right track, but it is completely not being applied to my answer. All it prints out in the console is the actual String array twice, without sorting anything.
public class arrayofstrings {
public static void sort(String[] a) {
String temp= "";
int min;
int i= 0;
for (int j=0; j<a.length-1; j++) {
[Code] ....
View Replies
View Related
Jul 9, 2014
What's that diameter? Create a new method for the circle class called diameter. Add this method to the circle class described on page 15-1. It should return a double that is the diameter of the circle. No parameters are passed to this method.
In a tester class, test the performance of your new diameter method as follows:
(Your project should have two classes, Tester and Circle.)
here is what i have so far:
public class Circle
{
public Circle (double r)
{
radius = r;
}
public double area()
{
double a = Math.PI * radius * radius;
[Code] ....
View Replies
View Related
Feb 19, 2014
This code is shown to eliminate "smearing":
public void paintComponent (Graphics g) {
g.setColor(Color.white);
g.fillRect(0,0,this.getWidth(), this.getHeight());
g.setColor(Color.green);
g.fillOval(x, y, 40, 40);
}
I had done all the previous code (in my own style) and found that the background rectangle was either being redrawn on its own, or there was something else removing the old circles from the screen. I then typed in the code from the previous page exactly as it was, to see if I had some change in syntax that would cause this, and it did the same thing.
Here's my code:
import javax.swing.*;
import java.awt.*;
public class SimpleAnimation {
int x, y;
private static final int HEIGHT = 600;
private static final int WIDTH = 600;
[Code] .....
Is this because I'm using JRE7? I can't find any documentation that indicates the repaint() method has changed since Java 5.
View Replies
View Related
Mar 19, 2014
Prompt: Write a class encapsulating the concept of a circle, assuming a circle has the following attributes: a Point representing the center of the circle, and the radius of the circle, and integer.
Include a constructor, the accessors and mutators, and methods toString and equals.
Also include methods returning the perimeter ( 2 x 𝜋 x 𝑟 ) and area ( 𝜋 x 𝑟^2) of the circle.
Write a client (application) class to test all the methods in your class. I started out trying to thing how to do this and I mapped out a certain idea but do not know how to incorporate the point represent the center of the circle. I am not sure how to proceed further..
import java.awt.*;
public class Circle {
public static void main(String[] args) {
final double PI = 3.14;
int x,y, radius = 4;
double area;
double perimeter;
[Code] ...
View Replies
View Related
Jan 6, 2015
I have two classes LightController & Circle. I need to use the LightController class to do the following:
Creates an instance of Circle with a diameter of 50 and a colour of OUColour.GREEN and assigns this new circle to the instance variable light.
Sets the xPos of light to 122.
Sets the yPos of light to 162.
I am struggling to write the correct line of code to set the colour to green and set diameter to 50.
Code for the two classes below.
001
import ou.*;
002
import java.util.*;
003
/**
004
* Class LightController
005
* This class uses the Circle class, and the Shapes window
[Code] ......
View Replies
View Related
Nov 21, 2014
What class does method Planet.values() in the code below belong to? I thought it belongs to java.lang.Enum but when I could not see it in Java API 7.
package enumeration;
public class EnumTest {
public static void main(String[] args) {
//Planet myPlanet = Planet.EARTH;
// Check arguments supplied
if (args.length != 1) {
System.err.println("Usage: java EnumTest <earth_weight>");
System.exit(-1);
[code]....
View Replies
View Related
Jun 30, 2014
how many types of inputting method in java?can you explain with examples?
View Replies
View Related
May 11, 2015
I am having trouble with methods. What I want to do is be able to create 4 types of strings under the same method, but only draw one of them at a time.
i.e
UI.initialise;
UI.addButton ("pipe", this::drain);
public void drain(){
this.pipe ("pipe1");
this.pipe ("pipe2");
[Code] ....
When I press the button "drain" it will print=
pipe1
pipe2
pipe3
pipe4
I am having a lot of difficulty just printing one out after each time I press drain.
"drain"
pipe1
"drain"
pipe2 etc..
View Replies
View Related
Jun 29, 2014
Trying to find a way to use primitive data types to overload sound()method. I can't seem to warp my head around using an int or a double to overload the method. And if I did, how do you call them in the main afterwards?
View Replies
View Related
Sep 1, 2014
I am trying to remove the duplicate elements from ArrayList using .contains() if elements are primitive datatype it works but user-defined datatype does not work.
public class UserBean {
String name;
String address;
public String getName() {
return name;
[code]....
View Replies
View Related
Aug 11, 2014
I am retrieving data in <rich:datatable> , but the default skin color is not being applied in my page. My web.xaml is as below
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>richFacesApp</display-name>
[Code] ....
I am using tomcat 7.0 and Richfaces 4.0
View Replies
View Related
Feb 4, 2015
I want to know is there any way we can call parent class method using child class object without using super keyword in class B in the following program like we can do in c++ by using scoop resolution operator
class A{
public void hello(){
System.out.println("hello");
}
}
class B extends A{
public void hello(){
//super.hello();
System.out.println("hello1");
[code]....
View Replies
View Related
Jan 8, 2014
I've 3 classes.
1. Circle
2. GetInputFromUser
3. testCircle
package ABC;
public class Circle {
private double radius;
public double getRadius() {
return radius;
[Code] .....
In the testCircle class, in the line: getRadius = ui1.GetInput();
It's showing the error: The method GetInput(float) in the type GetInputFromUser is not applicable for the arguments ()
And when I do: getRadius = ui1.GetInput(rad);
It's showing the error: rad cannot be resolved
View Replies
View Related
Feb 13, 2014
I am just trying to test this array, for a locker combination program that involves classes...but the array is printing out the whacky numbers for the location. When I try to call the method in the main, it does not work. How do I call a method that exist within a class into the main method?
public class locker {
public static void main(String[] args) {
CombinationLock();
[code]....
View Replies
View Related
Oct 23, 2014
I am trying to call a private method to another method that are located in the same class.
I am trying to call prepareString to the encode method below.
Java Code:
public class ShiftEncoderDecoder
private String prepareString(String plainText)
{
String preparedString = "";
for(int i = 0 ; i < plainText.length();i++)
if(Character.isAlphabetic(plainText.charAt(i)))
[Code] .....
View Replies
View Related
Feb 26, 2015
I am currently working on a dice game. I have a private method called rollDice and it performs the action of rolling two dice. For my project, I need to create another method called playerRolls and I am supposed to invoke the rollDice method in the playerRolls method and perform actions based off of that. My question right now is how do I invoke a method into another method of the same class?
View Replies
View Related
Aug 11, 2014
i am having a problem while calling a method..i am having a class
Java Code:
public class MySer implements Runnable {
public void getMessage(String msg)
{
...,
}..,
} mh_sh_highlight_all('java');
i use the above class in another class
[code]....
View Replies
View Related
May 20, 2015
In the process of creating a new class, I need to move my main method from the class SaveDate to the class DynamicTest. Below I have listed the code of both classes.The objective is to be able to run my program from the DynamicTest Class. I need understanding the process of moving my main method to a different class and creating an Object of a class and calling its method.
public class SaveData {
private static final Map<String, Object> myCachedTreeMap = new TreeMap<String, Object>();
public static final List<String> getLines(final String resourceParam, final Charset charset) throws IOException{
System.out.println("Please get: "+resourceParam);
if (myCachedTreeMap.containsKey(resourceParam) ) {
// Use the cached file, to prevent an additional read.
[Code] ......
View Replies
View Related