As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/

SELECT * FROM posts WHERE tid = 'PA PROGRAMMING THREAD'

16364666869100

Posts

  • KambingKambing Registered User regular
    GnomeTank wrote: »
    Kambing wrote: »
    GnomeTank wrote: »
    The thing about people who rally against OO because it's "powerful and you can hurt yourself with it" tend to be academic types who haven't actually written real software in their entire life. Yes, you can write shit code with it. I can write shit functional code with Lisp too. And I can write shit procedural code with C. Over years of experience doing OO, you learn how to avoid writing that shit code. You learn when you're "overdoing it" (we call this over engineering, it has a real term). You learn to sniff out very quickly when you've architected a system to be too complex or not complex enough.

    The reason that academics (in particular certain PL folk) don't like OO is because it precisely leads to overly complex code whereas functional styles lead to more concise, elegant code.

    There's a whole bunch of features mixed into the debate when it is phrased as "OO vs. functional" (like mutation, ADTs, polymorphism, etc.) so its not a cut-and-dry argument. However, after being in industry and academia now, I'm firmly in the functional side of things.

    I'm on the "correct tool for the job" side of things. In most cases, that ends up being a mixture of OO and functional design patterns. They actually mix incredibly well if you know what you're doing.

    The problem is too many people graduate from college and think they know what they are doing: They don't. It takes college + years of experience to actually know what you're doing, and the part that is optional is the college, not the years of experience. Not that college is bad, I recommend it for everyone. People just need to understand what a comp sci program is actually going to give you, and what it's not going to give you.

    Yep, I'm in that camp too. But in my experience is that, by far, functional programming --- namely immutability and all the great reasoning benefits you get from it --- is (should be) the common case. And then once you start going down that road, you find that OO programming on its own offers little additional benefit.

    @TwitchTV, @Youtube: master-level zerg ladder/customs, commentary, and random miscellany.
  • WeretacoWeretaco Cubicle Gangster Registered User regular
    Magic code line of the day. There is no else clause anywhere. So regardless of what happens... PSUB equals... itself :(
       IF OITYP GE 3 AND (RTN EQ 3 OR RTN EQ 6) THEN PSUB = PSUB
    

    Unofficial PA IRC chat: #paforums at irc.slashnet.org
  • EtheaEthea Registered User regular
    bowen wrote: »
    :rotate: is all you need Ethea... it's all you need.

    Nobody needs more than a single petaflop!

  • bowenbowen How you doin'? Registered User regular
    Weretaco wrote: »
    Magic code line of the day. There is no else clause anywhere. So regardless of what happens... PSUB equals... itself :(
       IF OITYP GE 3 AND (RTN EQ 3 OR RTN EQ 6) THEN PSUB = PSUB
    

    D:

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • SyphyreSyphyre A Dangerous Pastime Registered User regular
    What language is that in, Weretaco? There's a couple I could pick from.

  • AnteCantelopeAnteCantelope Registered User regular
    Does anyone here know much about Java GUIs? I always tend to lump as much stuff into constructors as I can, and I'm wondering if that's considered good or bad practice. Say I'm making a Frame that holds a bunch of Panels, I'll create and add the Panels in the Frame's constructor. Then if those Panels hold Buttons and TextAreas, I'll create and position those in the Panel's constructors.

    It feels a bit weird that 90% of my code is in the constructors for these objects, but it makes sense to me, because making these objects and positioning them is a one-time event that needs to happen at start-up, so constructors seem right to me.

    Is there a convention for this, either way?

  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Syphyre wrote: »
    What language is that in, Weretaco? There's a couple I could pick from.

    Looks like Fortran.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • WeretacoWeretaco Cubicle Gangster Registered User regular
    GnomeTank wrote: »
    Syphyre wrote: »
    What language is that in, Weretaco? There's a couple I could pick from.

    Looks like Fortran.

    pickBASIC (my lovely pit of hell)

    Unofficial PA IRC chat: #paforums at irc.slashnet.org
  • SyphyreSyphyre A Dangerous Pastime Registered User regular
    Weretaco wrote: »
    GnomeTank wrote: »
    Syphyre wrote: »
    What language is that in, Weretaco? There's a couple I could pick from.

    Looks like Fortran.

    pickBASIC (my lovely pit of hell)

    I had to ask because it didn't look quite like a Fortran program, and sure enough, a Basic variant. Well, it could always be worse, but I feel for ya.

  • CantidoCantido Registered User regular
    I've done plent of BSTs in C before, but this non-binary is killer, and I could use some help making it a reality:

    I have to make a pseudo ID3 Decision Tree. These are used to indicate pathways in decision making such as diagnosing a car or the Ken Flowchart and all that.

    Luckily I've been given a fixed set of decisions so it doesn't have to be generic. Each rule is called a Feature, and I have five of them. I put them in String Arrays, and then put those array in a shuffled Array List.
    public class main
    {
    	public static void main(String[] args)throws Exception
    	{
    	
    	//We are explicitly given the examples to use, so we create the features, 
    	//and the examples, by brute force.  The tree will be more dynamic.
    	
    	//1.  Make the light feature
    	String[] lightstatus = new String[5];
    	{
    		lightstatus[0] ="Dim";
    		lightstatus[1] ="Normal";
    	}
    	
    	
    	//2. Make the sound feature
    	String[] soundstatus = new String[3];
    	{
    		soundstatus[0] ="Normal";
    		soundstatus[1] ="Howl";
    		soundstatus[2] ="Screech";
    		soundstatus[3] ="Click";
    	}
    	
    
    	//3. Make the turnover feature
    	String[] turn = new String[1];
    	{
    		turn[0] ="no";
    		turn[1] ="yes";
    	}
    		
    	
    	//4. Make the fuel gauge feature
    	String[] fuelstats = new String[1];
    	{
    		fuelstats[0] ="not-empty";
    		fuelstats[1] ="empty";
    	}
    	
    	//5. Make the smell feature
    	String[] scents = new String[1];
    	{
    		scents[0] ="normal";
    		scents[1] ="gas";
    	}
    	
    	
    	//6. Make the problem feature
    	String[] problems = new String[4];
    	{
    		problems[0] ="battery";
    		problems[1] ="starter";
    		problems[2] ="solenoid";
    		problems[3] ="out-of-gas";
    		problems[4] ="flooding";
    	}
    	
    	ArrayList<String[]> Features = new ArrayList<String[]>();
    	
    	Features.add(lightstatus);
    	Features.add(soundstatus);
    	Features.add(turn);
    	Features.add(fuelstats);
    	Features.add(scents);
    		
    	//We have created the six features.  We must now make
    	//the examples based on the instructions.  We have five of them.
    	Example example1 = new Example(lightstatus[0], soundstatus[1], turn[1], fuelstats[0], scents[0], problems[0]);
    	Example example2 = new Example(lightstatus[1], soundstatus[2], turn[0], fuelstats[0], scents[0], problems[1]);
    	Example example3 = new Example(lightstatus[1], soundstatus[3], turn[0], fuelstats[0], scents[0], problems[2]);
    	Example example4 = new Example(lightstatus[1], soundstatus[0], turn[1], fuelstats[1], scents[0], problems[3]);
    	Example example5 = new Example(lightstatus[1], soundstatus[0], turn[1], fuelstats[0], scents[1], problems[4]);
    	
    	
    	//Now we put these five examples in an ArrayList.
    	//make an array list of Examples.
    	ArrayList<Example> Examples = new ArrayList<Example>();
    	Examples.add(example1);
    	Examples.add(example2);
    	Examples.add(example3);
    	Examples.add(example4);
    	Examples.add(example5);
    	
    	// Shuffle the elements in the list
    	Collections.shuffle(Features);
    	
    	//The Features Array List is now a shuffled tree.
    	//We will do a single loop that will serve as our stack.
    	
    	//First we take the top of the list and assign it to the root.
            //This line is not right
    	Tree id3 = new Tree((Feature)Features.get(0)));
    	
    

    The Features get shuffled, and then I take the first Feature (rule) and make it the root. All the different options of the feature need to become children. So if the first feature is "lightstatus", lightstatus is the root, and it can just have two children. One for Normal and one for Dim. If there are four options like with Sound Status, there needs to be four children. I've swapped the BST's left and right child architecture for an Array List of Nodes. But now I'm having trouble no what I need to do next. At this point I know which feature the root would be, but I'm getting my parameterization mixed up. The selected feature's variable name would be the root and it's array list of strings would be all the children. How do I specify that? I feel like I'm so close but I'm doing something retarded.

    This is my Node.
    import java.util.*;
    
    public class Node 
    {
    	public Node() 
    	{ 
    		children = new ArrayList<Node>(); 
    	}
    	public ArrayList<Node> getChildren() 
    	{ 
    		return children; 
    	}
    	
    	public void addChild(Node n) 
    	{ 
    		children.add(n);
    	}
    	public String getphrase() 
    	{ 
    		return phrase;
    	}
    	
    	public void setphrase(String newphrase) 
    	{ 
    		phrase = newphrase; 
    	}
    
    	private ArrayList<Node> children;
    	String phrase;
    	private boolean isUsed;
    	Node parent;
    	
    	public void setUsed(boolean isUsed) 
    	{
    		this.isUsed = isUsed;
    	}
    
    	public boolean isUsed() 
    	{
    		return isUsed;
    	}
    	//This method states if the node is a leaf 
    	public boolean isLeaf()
    	{
    		if (this.getChildren() == null)
    		return true;
    		
    		else
    		return false;
    	}
    
    }
    

    This is the tree so far.
    public class Tree 
    {
    	
    	public Node root;
    	public Node current = new Node();
    	Integer internalNumber = 0;
    	Integer height;
    	
    	//Constructors
    	public Tree() 
    	{
    		root = current;
    		root.parent = null;
    	}
    	
    	public Tree(Feature feature) 
    	{
    		root = current;
    		root.phrase = feature;
    		root.parent = null;
    	}
    	
    	//This method creates a tree with one root node,
    	//but it also creates the children too.
    	public  void Create(ArrayList<Feature> checklist)
    	{
    		root.phrase = name;
    		root.parent = null;
    	}//Finished
    	
    	
    	
    	//This method checks if a node is the root
    	public  boolean isRoot(Node nodeChecked)
    	{
    		if(nodeChecked.parent == null)
    		{
    			return true;
    		}
    		else
    		{
    			return false;
    		}
    	}//finished
    	
    	//This method saves the current node after Find
    	public  void SavePosition(Node saved)
    	{
    		saved = current;
    	}
    

    3DS Friendcode 5413-1311-3767
  • wildwoodwildwood Registered User regular
    edited April 2012
    @Cantido - it really seems like you want to be using Enums instead of String arrays for this. Using Enum objects would let you do everything the Arrays are doing, and let you add more, like possibly a 'getName' method for filling out the tree.

    One interesting example of Enums in a hierarchy: java.dzone.com/articles/enum-tricks-hierarchical-data

    Oh, and just one nitpick: in order for a BST to earn the 'S' in its name, I'm pretty sure it has to be sorted. It's not clear from your code above that any kind of sorting is happening, or even desired.

    Edit: wait, why are you representing this as a tree? If I'm understanding right, the nodes at each Feature level are identical, right? (I mean, with your "lightstatus" example above, will there be any difference at all between the children of "normal" and "dim"?) So far it sounds more like you're finding the right point in N-dimensional (or 'Feature'-dimensional) space for the diagnosis.

    wildwood on
  • CantidoCantido Registered User regular
    edited April 2012
    wildwood wrote: »
    @Cantido - it really seems like you want to be using Enums instead of String arrays for this. Using Enum objects would let you do everything the Arrays are doing, and let you add more, like possibly a 'getName' method for filling out the tree.

    One interesting example of Enums in a hierarchy: java.dzone.com/articles/enum-tricks-hierarchical-data

    Oh, and just one nitpick: in order for a BST to earn the 'S' in its name, I'm pretty sure it has to be sorted. It's not clear from your code above that any kind of sorting is happening, or even desired.

    Edit: wait, why are you representing this as a tree? If I'm understanding right, the nodes at each Feature level are identical, right? (I mean, with your "lightstatus" example above, will there be any difference at all between the children of "normal" and "dim"?) So far it sounds more like you're finding the right point in N-dimensional (or 'Feature'-dimensional) space for the diagnosis.

    You're right about the enum, that might do the trick. As for the "Search" part, I don't think it's desired. The idea is to try different Features for roots, and see what makes the tree largest and smallest. The algorithm takes them in at random first, and later I will force in different roots and count the total nodes. The lesson is that good indexing can make or break Inductive Machine Learning (at the undergrad level anyway)

    I will pseudo out the algorithm:
    1. Take the first Feature, make it the root, and it's children are the different options.
    2. If there are more than one node at this level, create the same number of branches for each node at this level
    
    3.for (all examples in the Examples List)
    {
        *"parse" the Example down the path whose branch agrees with its value(s) for the applicable Feature
        * If all the Examples gathered at the same location have the same "solution," STOP
        * Continue
    }
    4. Take the next Feature, which will be used to obtain the next level, and return to 2.
    

    As the levels get added, examples follow the newly created children each time, so it quickly forges reliable case based reasoning.

    Cantido on
    3DS Friendcode 5413-1311-3767
  • DrunkMcDrunkMc Registered User regular
    Enums are fucking awesome. This example from Oracle's website showed me how bad ass they can be:
    public enum Planet {
        MERCURY (3.303e+23, 2.4397e6),
        VENUS   (4.869e+24, 6.0518e6),
        EARTH   (5.976e+24, 6.37814e6),
        MARS    (6.421e+23, 3.3972e6),
        JUPITER (1.9e+27,   7.1492e7),
        SATURN  (5.688e+26, 6.0268e7),
        URANUS  (8.686e+25, 2.5559e7),
        NEPTUNE (1.024e+26, 2.4746e7),
        PLUTO   (1.27e+22,  1.137e6);
    
        private final double mass;   // in kilograms
        private final double radius; // in meters
        Planet(double mass, double radius) {
            this.mass = mass;
            this.radius = radius;
        }
        public double mass()   { return mass; }
        public double radius() { return radius; }
    
        // universal gravitational constant  (m3 kg-1 s-2)
        public static final double G = 6.67300E-11;
    
        public double surfaceGravity() {
            return G * mass / (radius * radius);
        }
        public double surfaceWeight(double otherMass) {
            return otherMass * surfaceGravity();
        }
    }
    

  • jackaljackal Fuck Yes. That is an orderly anal warehouse. Registered User regular
    Pluto 8->

  • bowenbowen How you doin'? Registered User regular
    Apparently we have 230 some odd objects in our solar system around pluto's size.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    That enum class is awesome, but I never really got the point of doing that. That could be done via a regular old class right? Stupid Java and their stupidly powerful enums.

  • bowenbowen How you doin'? Registered User regular
    You could but you wouldn't have default values already in there. I guess.

    Planet.Earth is different from Planet Earth = new Planet(...);

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    Yeah if you didn't have a String constructor I guess. Planet Earth = new Planet("Earth"); then do a switch statement on the string or do a bunch of ifs.

  • CantidoCantido Registered User regular
    edited April 2012
    I'm doing an enums version.
    public class main
    {
    	public enum lightstatus {Dim, Normal}
    	public enum soundstatus {Normal, Howl, Screech, Click}
    	public enum turn {no, yes}
    	public enum fuelstats {notempty, empty}
    	public enum scents {normal, gas}
    	public enum problems {battery, starter, solenoid, outofgas, flooding}
    	
    	public static void main(String[] args)throws Exception
    	
    	{
    	
    	ArrayList<Enum> Features = new ArrayList<Enum>();
    	
    	Features.add(lightstatus);
    	Features.add(soundstatus);
    	Features.add(turn);
    	Features.add(fuelstats);
    	Features.add(scents);
    		
    	//We have created the six features.  We must now make
    	//the examples based on the instructions.  We have five of them.
    	Example example1 = new Example(lightstatus.Dim, soundstatus.Howl, turn.yes, fuelstats.notempty, scents.normal, problems.battery);
    	Example example2 = new Example(lightstatus.Normal, soundstatus.Screech, turn.no, fuelstats.notempty, scents.normal, problems.starter);
    	Example example3 = new Example(lightstatus.Normal, soundstatus.Click, turn.no, fuelstats.notempty, scents.normal, problems.solenoid);
    	Example example4 = new Example(lightstatus.Normal, soundstatus.Normal, turn.yes, fuelstats.empty, scents.normal, problems.outofgas);
    	Example example5 = new Example(lightstatus.Normal, soundstatus.Normal, turn.yes, fuelstats.notempty, scents.gas, problems.flooding);
    	
    	
    	//Now we put these five examples in an ArrayList.
    	//make an array list of Examples.
    	ArrayList<Example> Examples = new ArrayList<Example>();
    	Examples.add(example1);
    	Examples.add(example2);
    	Examples.add(example3);
    	Examples.add(example4);
    	Examples.add(example5);
    	
    	// Shuffle the elements in the list
    	Collections.shuffle(Features);
    
    The thing is I need to redefine my Example class. I just need it to take in one value from each enum, but how do I specify that? After all, they are no longer Strings, and I don't think I'm allowed to specify that it takes in enums.
    public class Example 
    {
    	
    	protected String lights;
    	protected String sound;
    	protected String turnover;
    	protected String fuelgauge;
    	protected String smell;
    	protected String problem;}
    	
    	
    	//Constructor for a parameter
    	public Example (main.lightstatus, main.soundstatus, main.turn, main.fuelstats, main.scents, main.problems)
    	{
    		this.lights= lights;
    		this.sound= sound;
    		this.turnover= turnover;
    		this.fuelgauge= fuelgauge;
    		this.smell= smell;
    		this.problem= problem;
    
    	}
    
    	
    
    }
    

    Cantido on
    3DS Friendcode 5413-1311-3767
  • IncindiumIncindium Registered User regular
    edited April 2012
    Java style enums is pretty much the only thing from Java that I wish C# had.

    Oh and BTW I learned today that Excel will only open .csv files properly formatted if they are actually tab delimited D: :rotate: O_o

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • bowenbowen How you doin'? Registered User regular
    edited April 2012
    Are you sure? Are you sure it isn't using apostrophe delimination for colums (way more common than you'd think) in the csv?

    Something like this:

    Typical CSV file I see:
    '12121344','My subject','Author: O'Brian'
    

    Tab delimited file
    1212134\tMy Subject\tAuthor: O'Brian
    

    How a CSV should be:
    1212134,My Subject,Author: O'Brian
    

    bowen on
    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • IncindiumIncindium Registered User regular
    edited April 2012
    http://www.codejacked.com/those-fickle-csv-files/

    We ran into this on a result set created by MSSQL mail and tabs fixed the issue.

    You are right though that with me standalone testing a simple .csv file I just created by hand it is properly opening up. Not sure what the issue is.

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    There is nothing Java style enums do that you can't do with static readonly or const variables in C# and a protected constructor.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • bowenbowen How you doin'? Registered User regular
    Looks like it's those god damned quotes, they never work right in parses for some reason incindium. My go to is either tab or pipe delimited.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • IncindiumIncindium Registered User regular
    edited April 2012
    GnomeTank wrote: »
    There is nothing Java style enums do that you can't do with static readonly or const variables in C# and a protected constructor.

    Yeah but the Java version is more elegant in this case
    contrast/compare:
    http://stackoverflow.com/questions/469287/c-sharp-vs-java-enum-for-those-new-to-c

    Edit... the C# extension method version is pretty cool though

    Incindium on
    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • bowenbowen How you doin'? Registered User regular
    I use pipe delimitation internally so tab delimited by default.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Incindium wrote: »
    GnomeTank wrote: »
    There is nothing Java style enums do that you can't do with static readonly or const variables in C# and a protected constructor.

    Yeah but the Java version is more elegant in this case
    contrast/compare:
    http://stackoverflow.com/questions/469287/c-sharp-vs-java-enum-for-those-new-to-c

    Edit... the C# extension method version is pretty cool though

    Except it's really not that much more elegant? It's just syntactic sugar around the same thing. The biggest differences are 'class' instead of 'enum' and the Values property, which isn't even technically necessary, you could do the same thing with simple reflection.

    I don't care if C# adds the feature, it just annoys me when people say "This isn't possible in C#!!!!!"...when it is completely possible, you just have to think about it for a second.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • IncindiumIncindium Registered User regular
    Incindium wrote: »
    http://www.codejacked.com/those-fickle-csv-files/

    We ran into this on a result set created by MSSQL mail and tabs fixed the issue.

    You are right though that with me standalone testing a simple .csv file I just created by hand it is properly opening up. Not sure what the issue is.

    I figured it out.

    If the file is ASCII: Excel opens .csv files that are comma delimited and properly breaks the fields out in multiple columns.
    If the file is Unicode: Excel opens .csv files that are comma delimited and puts all the fields in one column.
    If the file is Unicode: Excel opens .csv files that are tab delimited and properly breaks the fields out in multiple columns.

    steam_sig.png
    Nintendo ID: Incindium
    PSN: IncindiumX
  • DrunkMcDrunkMc Registered User regular
    edited April 2012
    Incindium wrote: »
    Java style enums is pretty much the only thing from Java that I wish C# had.

    Oh and BTW I learned today that Excel will only open .csv files properly formatted if they are actually tab delimited D: :rotate: O_o

    I use .csv's all the time with commas in excel. Something else must be a miss.

    EDIT: Whoops you figured it out already.

    DrunkMc on
  • bowenbowen How you doin'? Registered User regular
    One day multibyte encoding will be fun... one day.

    not a doctor, not a lawyer, examples I use may not be fully researched so don't take out of context plz, don't @ me
  • urahonkyurahonky Registered User regular
    Ugh the newest update to Netbeans does something very annoying. When you do "Fix Imports" and you have two or more in the same package it imports the entire package.

    So instead of:

    "import javax.swing.JFrame;
    import javax.swing.JTabbedPanes;"

    It just does: "import javax.swing.*;"

  • Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    Rails question: what exactly does it mean when I define Users as a resource? This is one of the thing that was explained in the book and that I have now forgotten.

    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    In your routes? It means that Users are going to be acted on with CRUD (create, read, update, destroy) methods in a RESTful manner.

  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Rails question: what exactly does it mean when I define Users as a resource? This is one of the thing that was explained in the book and that I have now forgotten.

    It means you've done "map.resource" in your route file, and that it's now going to treat that route as a complete resource path. That means the controller needs to support get, put, index, delete, etc. You can tweak what verbs actually need to be supported at the time of mapping, but without specifying, it's going to assume all the CRUD operations are there. Essentially, resource mapping is the heart of RESTful in rails.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • Mike DangerMike Danger "Diane..." a place both wonderful and strangeRegistered User regular
    Solid. I'll probably be back here in a few hours with more Rails questions...I'm almost done with the Hartl tutorial now and I think I'm ready to start wrapping my brain around this app idea that I had.

    Steam: Mike Danger | PSN/NNID: remadeking | 3DS: 2079-9204-4075
    oE0mva1.jpg
  • CantidoCantido Registered User regular
    edited April 2012
    wildwood wrote: »
    @Cantido - it really seems like you want to be using Enums instead of String arrays for this. Using Enum objects would let you do everything the Arrays are doing, and let you add more, like possibly a 'getName' method for filling out the tree.

    One interesting example of Enums in a hierarchy: java.dzone.com/articles/enum-tricks-hierarchical-data

    Oh, and just one nitpick: in order for a BST to earn the 'S' in its name, I'm pretty sure it has to be sorted. It's not clear from your code above that any kind of sorting is happening, or even desired.

    Edit: wait, why are you representing this as a tree? If I'm understanding right, the nodes at each Feature level are identical, right? (I mean, with your "lightstatus" example above, will there be any difference at all between the children of "normal" and "dim"?) So far it sounds more like you're finding the right point in N-dimensional (or 'Feature'-dimensional) space for the diagnosis.

    @wildwood I made an enum version of the six Features so they look like this. Instead of put them in main I gave each Enum it's own file so I wouldn't have to do main.enumname everywhere. One final thing I want to do is put those enums in an ArrayList and shuffle them, because I will take the order and build a tree with it. But

    ArrayList<Enum> Features = new ArrayList<Enum>();

    Is not allowed.
    public class main
    {
    	
    	public static void main(String[] args)throws Exception
    	
    	{
    	
    	ArrayList<Enum> Features = new ArrayList<Enum>();
    	
    	Features.add(lightstatus);
    	Features.add(soundstatus);
    	Features.add(turn);
    	Features.add(fuelstats);
    	Features.add(scents);
    		
    	//We have created the six features.  We must now make
    	//the examples based on the instructions.  We have been given five different examples.
    	Example example1 = new Example(lightstatus.Dim, soundstatus.Howl, turn.yes, fuelstats.notempty, scents.normal, problems.battery);
    	Example example2 = new Example(lightstatus.Normal, soundstatus.Screech, turn.no, fuelstats.notempty, scents.normal, problems.starter);
    	Example example3 = new Example(lightstatus.Normal, soundstatus.Click, turn.no, fuelstats.notempty, scents.normal, problems.solenoid);
    	Example example4 = new Example(lightstatus.Normal, soundstatus.Normal, turn.yes, fuelstats.empty, scents.normal, problems.outofgas);
    	Example example5 = new Example(lightstatus.Normal, soundstatus.Normal, turn.yes, fuelstats.notempty, scents.gas, problems.flooding);
    

    This is my new example class. This works out really well.
    * Each Example has one value for the six different features that exist.
     */
    public class Example 
    {
    	
    	protected lightstatus lights;
    	protected soundstatus sound;
    	protected turn turnover;
    	protected fuelstats fuelgauge;
    	protected scents smell;
    	protected problems problem;
    	
    	
    	//Constructor for a parameter
    	public Example (lightstatus lights, soundstatus sound, turn turnover, fuelstats fuelgauge, scents smell, problems problem)
    	{
    		this.lights= lights;
    		this.sound= sound;
    		this.turnover= turnover;
    		this.fuelgauge= fuelgauge;
    		this.smell= smell;
    		this.problem= problem;
    	}
    }
    

    EDIT - making changes....

    Cantido on
    3DS Friendcode 5413-1311-3767
  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Solid. I'll probably be back here in a few hours with more Rails questions...I'm almost done with the Hartl tutorial now and I think I'm ready to start wrapping my brain around this app idea that I had.

    Rails is pretty sweet. Welcome to awesomeville when it comes to writing RESTful MVC webapps.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • admanbadmanb unionize your workplace Seattle, WARegistered User regular
    Rails is still my favorite thing to work in.

  • GnomeTankGnomeTank What the what? Portland, OregonRegistered User regular
    Yeah, if the pay wasn't shit compared to what I do in the C#/line-of-business world, I'd switch my career to rails...but I just can't make what I make in that field.

    Sagroth wrote: »
    Oh c'mon FyreWulff, no one's gonna pay to visit Uranus.
    Steam: Brainling, XBL / PSN: GnomeTank, NintendoID: Brainling, FF14: Zillius Rosh SFV: Brainling
  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    When did Perl introduce the /r modifier on substitution? 5.8.8 doesn't seem to recognize it.

    borb_sig.png
This discussion has been closed.