0

Bellow are 2 files for Pie, First is simple. It works but needs PieJavaPizza to have shown inputs. For slice and type. Radius is always a power of 2. And I am stuck.

Is it possible to make

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.text.NumberFormat;

Work with objects in harmony with input types?
*I know difference of input with entering manually IE: How many rabbits do you have?: 0. VS There are 0 rabbits. Strings and Int are good for that.

I wish to know how does one input objects like you were asked how many there were or whats the name of such and such. *Bellow are codes of my project test and a jpeg of dot operator errors. Pie compiled fine, PieJavaPizza only came with dot operator errors.

Please help me, and thanks for the paitence!

*link at bottom shows compile errors, I just need basic knowledge on how to input objects!

Base Class:

//Class name, Pie! - For objects to work, must one a single Class name. 
class Pie {
//Instance variables 
  int slice;
  int radius;
  String type;
//Method
  void pizza() {

   System.out.println("Mmmmmm Pizza!");
  }
}


Object Class:

i

mport java.io.* ;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.text.NumberFormat;

//Just a main method - Here is where the object is in play. Must have Class Pie in front for object to be functional.
class PiePizzaJava {
 public static void main(String[] args) {
//Pizza Object
  Pie one = new Pie();
//Type of pizza - Using Input for what pizza ya want
  System.out.println("Please Enter In The Pizza you wish to make: ");
  one.type ();
//Dot operator to set slices of pizza
  one.slice ();
//Dot operator is always set to a 2 equation radius
  one.radius ();

//pizza() method
  one.pizza();
  }
}

http://www.codingforums.com/attachment.php?attachmentid=7271&d=1238348947

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by VernonDozier
0

The code and the description are pretty confusing to follow.

//Pizza Object
  Pie one = new Pie();
//Type of pizza - Using Input for what pizza ya want
  System.out.println("Please Enter In The Pizza you wish to make: ");
  one.type ();
//Dot operator to set slices of pizza
  one.slice ();
//Dot operator is always set to a 2 equation radius
  one.radius ();

I don't know what you are doing in lines 5, 7, and 9, but it looks like type (), slice (), and radius () are supposed to be setter functions perhaps? In which case, you need to make sure the functions exist in your Pie class:

// code below is inside Pie class
    public void setslice (int value)
    {
        slice = value;
    }

Call this from PiePizzaJava main function like this:

Pie one = new Pie ();
one.setSlice (6);
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.