say I want to create a class Bitchand in Bitch I want it to perform a mathmetical operation (whore = 10 x 50 ^ 5) and return a simple double valuehow can I call that value of whore from the class bitch to use in my public static void main? (As in, take the value of whore and add 50 to it in the public main)( or just display whore in a JPoptionpane.)[Edited on October 19, 2005 at 10:17 PM. Reason : d]
10/19/2005 10:16:45 PM
public class Bitch{ //same for all Bitches static double ovaries = 2.0 //different for each bitch double slutFactor; public double whore() { return 10f * slutFactor ^ ovaries; } public static double staticWhore() { //since this is static we can't use the instance variable slutFactor // lets use a normal value (like 50, for example Joie would be 9813598 and sarose 981359898358913509896426249861938619305 ) double slutFactor = 50; return 10f * slutFactor ^ ovaries; } public static void main(String[] args) { Bitch sarose = new Bitch(); sarose.slutFactor = 981985198f; double sexLikelihood = sarose.whore(); //or double sexLiklihood = Bitch.staticWhore(); }}
10/19/2005 10:28:15 PM
I laughed and I learnedamazing wolf web
10/19/2005 10:29:45 PM
something like this:
public class Witch{ private double where = 10 * Math.pow(50,5); public void setWhere(double d) { where = d; } public double getWhere() { return where; } public static void main { Witch myWitch = new Witch(); double asdf = myWitch.getWhere(); asdf += 50; System.out.println("asdf = " + asdf);}
10/19/2005 10:31:51 PM
im just having trouble understanding classes.I could do this all in one public main, but I know I could make it less messy with classes.
10/19/2005 10:33:11 PM
take a look at the concepts in "Classes I", "Classes II", and "Classes III" here:http://www.cs.umbc.edu/courses/undergraduate/202/fall05/schedule.shtmlit's C++ instead of java but the ideas are the same.
10/19/2005 10:39:49 PM
it's really easy once you get itsay you have a factory that makes wigets.Now this factory makes 3 different kind of widgets: sprocket, gear and chainso lets make a class Widget
public class Widget{ public static Material _my_material = Material.STEEL; //Constructor makes a single Widget public Widget() { }}
public class Gear extends Widget{ //I already have a material public static boolean has_teeth = true; //this is something that is true for ALL gears. //Variables that are specific to a single instance or type of gear! public int num_teeth, size_teeth, diameter, pitch; //Constructor public Gear(int num_teeth, int size_teeth, int diameter, int pitch) { this.num_teeth = num_teeth //set the number of teeth for THIS gear this.diameter = diameter //set the diameter for THIS gear! ..... } public Material getMaterial() { return _my_material; } public static Main(....) { //lets make multiple gears and put them together with a Chain Gear gear1 = new Gear(1,2,3,4); //make a simple Gear Gear gear2 = new Gear(4,3,2,1); //make another Gear Material m = gear1.getMaterial //m will ALWAYS be Steel because ALL Widgets are steel if ( gear1.has_teeth && gear2.has_teeth ) { //always enter this block since ALL gears have teeth } }}
10/19/2005 10:48:14 PM
Another n00b questionsay I am writing writing a Slut public classI want to take this:
inputStr = JOptionPane.showInputDialog(null, "Enter Dicks sucked:");dicksSucked = Double.parseDouble(inputStr);inputStr = JOptionPane.showInputDialog(null, "Enter Pussies Licked:");pussiesLicked = Double.parseDouble(inputStr);
public class whoreLevel {double x;x = dicksSucked * pussiesLickedreturn x}
JOptionPane.showMessageDialog(null, "Your chance of contracting HIV is: " + whoreLevel + "%");}
10/24/2005 3:20:14 PM
for one, you're placing too much emphasis on the "main class". There is no "main class" - each class has it's own separate functionality. If you are actually talking about the "main" method, then that is even worse. If you're trying to write programs with GUIs and elements like JOptionPanes, you really really need to get the class and division of labor concepts down.
10/24/2005 4:28:06 PM
Im use to visual basic. Each button did something when you wanted it to. You wrote code for it and that was it.
10/24/2005 4:50:35 PM
[an elaboration on the differences between procedural programming and object-oriented programming goes here]
10/24/2005 4:54:19 PM
10/24/2005 9:55:56 PM