Adult Content Warning

This community may contain adult content that is not suitable for minors. By closing this dialog box or continuing to navigate this site, you certify that you are 18 years of age and consent to view adult content.

Programming -- shell / java / c# / python / ada / lisp

Discussion in 'Technical Board' started by Nettdata, Dec 1, 2009.

  1. LatinGroove

    LatinGroove
    Expand Collapse
    Emotionally Jaded

    Reputation:
    9
    Joined:
    Jun 28, 2010
    Messages:
    584
    Location:
    Texas
    I'm working on some java homework and I honestly have no idea what the fuck I'm doing. It's been forever since I worked on any programming so I might as well be working on particle physics.

    The whole idea is working with setters and getters. Any ideas on how to get this fucking thing to compile? Here is essentially what should be output when compiled:

    Name: Bob
    Age: 15
    Type of Student: High School

    Name: ted Age: 35
    Type of Student: College

    Here is what I have for the StudentClient.java file which I am NOT allowed to modify in any way whatsoever.

    Code:
    public class StudentClient{
      public static void main( String [] args ){
        Student student1 = new Student("Bob", 15);
        Student student2 = new Student("Jan", 13);
        System.out.println("Name: " + student1.getName());
        System.out.println("Age: " + student1.getAge());
        System.out.println("Type of Student: " + student1.determineTypeOfStudent());
    
        System.out.println("\n" + student2.fullString());
        System.out.println("Type of Student: " + student2.determineTypeOfStudent());
    
        student1.setName("Ted");
        student1.setAge(35);
    
        System.out.println("\n" + student1.fullString());
        System.out.println("Type of Student: " + student1.determineTypeOfStudent());
      } 
    }  
    
    
    
    Here is the Student.java file which I can modify in anyway I see fit. I have blocked off a section of code just so I can get attempt to get the thing to run. Here is the error I am getting "Method determineTypeOfStudent in class Student cannot be applied to given types

    Reason: actual and formalt argument lists differ in length."

    Code:
    public class Student{
        //define variables
        
        private String name;
        private double age;
        
        //Student constructor
        public Student(String newName, double newAge) {
            setName(newName);
            setAge(newAge);
        }
        
        //Mutator to set student type
        public void setName(String newName) {
            name = newName;
        }
        
        //Accessor to get the student type
        public String getName() {
            return name;
        }
        
        //Mutator to check validity of data
        
        public void setAge(double newAge) {
            if (newAge >= 0) {
                age = newAge;
            }else {
                System.out.println("Age cannot be a negative.");
            }
        }
    
        //Accessor to get the student age
        
        public double getAge() {
            return age;
        }
        
        //Method to return student type, name, and age
        public String fullString() {
            return  ("\nName: " + name + "\nAge: " + age);
        }
    
        //method determines type of student
        public String determineTypeOfStudent(Student TypeOfStudent) {
            if (TypeOfStudent.age >= 0 & age <= 4){
                return "Preschool";
                //System.out.println("Preschool");
            /*}else if (newAge = 5){
                System.out.println("Kindergarten");
            }else if (newAge >= 6 & newAge <= 10) {
                System.out.println("Elementary School");
            }else if (newAge >= 11 & newAge <= 13) {
                System.out.println("Middle School");
            }else if (newAge >= 14 & newAge <= 17) {
                System.out.println("High School");
            }else if (newAge >= 18) {
                System.out.println("College");
            }    */
        }   else{    
            return null;
        
    } 
    }
    }
    
    
    
    
     
  2. LatinGroove

    LatinGroove
    Expand Collapse
    Emotionally Jaded

    Reputation:
    9
    Joined:
    Jun 28, 2010
    Messages:
    584
    Location:
    Texas
    Does this make sense to everyone else? Ignore the fact it actually compiles.

    Code:
    public class Student{
        //define variables
        
        private String name;
        private double age;
        
        //Student constructor
        public Student(String newName, double newAge) {
            setName(newName);
            setAge(newAge);
        }
        
        //Mutator to set student name
        public void setName(String newName) {
            name = newName;
        }
        
        //Accessor to get the student type
        public String getName() {
            return name;
        }
        
        //Mutator to check validity of data
        
        public void setAge(double newAge) {
            if (newAge >= 0) {
                age = newAge;
            }else {
                System.out.println("Age cannot be a negative.");
            }
        }
    
        //Accessor to get the student age
        
        public double getAge() {
            return age;
        }
        
        //Method to return student name and age
        public String fullString() {
            return  ("\nName: " + name + "\nAge: " + age);
        }
    
        //method determines type of student
        public String determineTypeOfStudent() {
            if (age > 0 & age < 4){
                return "Preschool";
            }else {if (age >= 5 & age <= 5){
                return "Kindergarten";
            }else {if (age >= 6 & age <= 10) {
                return "Elementary School";
            }else {if (age >= 11 & age <= 13) {
                return "Middle School";
            }else {if (age >= 14 & age <= 17) {
                return "High School";
            }else {if (age >= 18) {
                return "College";
            }else {
                return null;
            }
            }
            }
            }
            }
            }
        }
    }
     
  3. GremlinD

    GremlinD
    Expand Collapse
    Village Idiot

    Reputation:
    9
    Joined:
    Nov 5, 2009
    Messages:
    10
    First, your definition for the determineTypeOfStudent method requires an input parameter. When your code calls it, you aren't passing it that parameter. So it should be:

    Code:
     student1.determineTypeOfStudent(student1)
    Secondly, in that method, your test for "Kindergarten" won't compile. In an IF statement, the test should use == to test for equality.

    I took your code and was able to get it to work with those changes.
     
  4. AFHokie

    AFHokie
    Expand Collapse
    Emotionally Jaded

    Reputation:
    112
    Joined:
    Apr 13, 2010
    Messages:
    577
    Location:
    Manassas, VA
    Basically, I'm at the starting line, but I have no idea what direction I'm supposed to proceed. I'd like to learn SQL. However, other than knowing SQL is database management, I'm at a loss where to start to learn it. Based on what's posted in the thread, I do have a couple ideas for projects but I'm not sure where to go for basic learning. I found Microsoft's offering: https://www.microsoft.com/learning/en-us/sql-training.aspx However, I tend to learn and retain better with a real book in my hands. I found O'Reilly's Learning SQL http://shop.oreilly.com/product/9780596007270.do

    Are their other books or websites anyone would suggest I look up?
     
  5. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
  6. Clutch

    Clutch
    Expand Collapse
    Emotionally Jaded

    Reputation:
    412
    Joined:
    Oct 19, 2009
    Messages:
    3,474
    The basics of SQL are pretty simple and easy to learn. Beyond that it gets pretty specific based on what you're trying to do and which database you're using.

    I got my first job as a SQL developer having never written a line of SQL before I started, and I got up to speed fast enough that they never noticed. INSERT, UPDATE, DELETE, and JOIN are what you need. Anything beyond that is just being more efficient.
     
  7. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    Yes and no.

    Data model design is pretty key, but is hard to learn from books... experience and exposure to other projects is what really helps that.

    If you're just doing some basic programming of a simple system, INSERT/UPDATE/DELETE, cursors, EXPLAIN PLAN, and the various joins will get you through.

    As you get more advanced, and have to incorporate things like performance, security, and data management, you learn about stored procedures, views, materialized view, partitioning, locking strategies, triggers, replication, memory management, etc.

    Then, if you're really fucking insane, you get into data warehousing.
     
  8. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    Can Anyone recommend a PostGreSQL hosting service? Are they all the same and is there any noticeable difference between any of them?
     
  9. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    I’d just use AWS RDS Postgres. Pretty cheap, well managed (backups, encryption, firewalling, etc).
     
  10. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    Got it. I'll sign up for an account now. Thank you.
     
  11. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    I don't know what your requirements are, but I use AWS RDS in quite a few Production environments. I run this site (with mysql and postgres) for about $10 a month with a hosted VM at Linode, where I have a basic Ubuntu image that I then install/run whatever I want. Depends on how handy you are with sysadmin stuff, and what you're looking to do with it.

    For least hassle, yeah, AWS RDS is hard to beat... especially with their backup/recovery/admin stuff being as automatic and simple as it is. It can also scale pretty fucking big with a push of a button.
     
  12. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    I'll be putting it into production but I doubt I will have to scale very large at all. It's simply for a python portfolio / resume for an app I am building with Django 2.X. I don't expect many to use it. In my case, the less hassle / easier Amazon makes it, the better.
     
  13. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    I have 3 clients that we rolled out RDS PG with, some at pretty serious scale, and it's going rock solid... including read-replicas. It's a pretty impressive offering from AWS. (We also use a ton of Dynamo and Redshift).
     
  14. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    If you're REALLY looking to save cash, maybe even look to: Aurora Serverless.

    https://aws.amazon.com/rds/aurora/serverless/

    It's mysql instead of postgres, but that shouldn't matter for what you're doing.

    But it's fucking CHEAP... only pay for what you use, per second, unlike RDS where you're paying for an instance.

    Worth checking into if you're paying it yourself and it's not a crazy low latency, high perf PG gig.
     
  15. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    Personally I'd pick PG over Mysql any day, but for something like what you're looking at doing, the serverless, pay-per-second-of-use features would be worth "downgrading" to mysql.

    $0.02
     
  16. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    I know nothing about Dynamo or Redshift. I only have a moderate grasp on Python with some JavaScript and HTML. Yes, I will be paying for it myself. I am also self-taught. I'm enrolled in University for Comp Networking but I enjoy programming much more.
     
  17. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    MySQL it is then.
     
  18. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    Yeah, in your case, it's totally worth it.

    Again, you want the SERVERLESS version, not just RDS MySql...
     
  19. Nettdata

    Nettdata
    Expand Collapse
    Emotionally Jaded

    Reputation:
    1,801
    Joined:
    Feb 14, 2006
    Messages:
    17,747
    If anyone is at all interested in how to spin up a ton of the AWS services, feel free to ask. I oversee a lot of Lambda/Serverless and DB, EC2, S3, Redshift, Dynamo, SQS/SNS, etc services and lead teams that build that shit out to some pretty big, global scale.

    I also do a lot of stream processing and machine learning at scale... things like Kinesis and Kinesis Firehose, Sagemaker, Deeplens, Glue, Athena, Redshift/Redshift specturm, etc.

    Most of it is used for real-time fraud detection and alerting based on individual end-user behaviour, etc, but it's pretty cool shit.

    (It's basically the Apache Kafka/Spark stuff rolled out into AWS services).
     
  20. redbullgreygoose

    redbullgreygoose
    Expand Collapse
    Disturbed

    Reputation:
    2
    Joined:
    Oct 19, 2009
    Messages:
    495
    If you don't mind, can you give me a (very) basic explanation how severless programming works? Where does the data go? I see/hear it mentioned as offhand comments in tutorials all the time but where does the data get stored?