d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Make Me A Better Programmer - From Step 1
Prev1161718192056Next
Add Reply New Topic New Poll
Member
Posts: 4,541
Joined: Sep 15 2011
Gold: 10,391.00
Dec 7 2012 12:50pm
Quote (Eep @ Dec 7 2012 04:09am)
and Discrete Structures (not looking forward to this one based on some minor horror stories I've heard ~_~)


is that Algorithms, or like a pre-cursor to it?
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Dec 7 2012 03:20pm
Quote (irimi @ Dec 7 2012 01:50pm)
is that Algorithms, or like a pre-cursor to it?


a pre cursor. It is a proof-based class (stuff like induction and the sort)

edit: It is a junior level math course

This post was edited by Eep on Dec 7 2012 03:21pm
Member
Posts: 4,541
Joined: Sep 15 2011
Gold: 10,391.00
Dec 8 2012 12:45am
Sounds a lot like http://courses.csail.mit.edu/6.042/fall12/ then. one of the funnest classes I ever took (and in the scheme of things, pretty easy too).

If it's anything like 042, then it's probably one of the most important classes you'll ever take. It's sort of Geometry but for CS. (In case you didn't get that analogy -- you don't take geometry in high school to learn geometry... you take it to learn logic).

Intro to Algorithms, on the other hand, was brutal.

This post was edited by irimi on Dec 8 2012 12:48am
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Dec 8 2012 01:42am
Quote (irimi @ Dec 8 2012 01:45am)
Sounds a lot like http://courses.csail.mit.edu/6.042/fall12/ then.  one of the funnest classes I ever took (and in the scheme of things, pretty easy too).

If it's anything like 042, then it's probably one of the most important classes you'll ever take.  It's sort of Geometry but for CS.  (In case you didn't get that analogy -- you don't take geometry in high school to learn geometry... you take it to learn logic).

Intro to Algorithms, on the other hand, was brutal.


yeah algorithms is after this one and I have heard from a friend in the class that the only way people are passing is because of loads of extra credit given by the professor after she realized it was insanely hard
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Dec 12 2012 05:30am
I am now a premium member in Dreamspark ;D
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Jan 22 2013 07:35pm
So I got my 2 past cs professors back - the nut and the unix nut.

I love em both though so it's okay.

Haven't met my OOP prof. yet.

Discrete Math guy seems pretty cool, bit rushy in his lectures but hopefully its just because the material is easy right now.


course descrips agan, if anyone is interested:

CMP SCI 2261 Object-Oriented Programming (3) Prerequisites: CMP SCI 2250. Introduces object-oriented concepts, terminology, and notation (UML) using Java. Covers encapsulation, classes, objects, inheritance, and the use of class libraries. Additional topics may include graphical user interfaces, applets, and related tools and technologies.

CMP SCI 2700 Computer Organization and Architecture (3) Prerequisite: CMP SCI 2250. Introduces details of computer systems from architectural and organizational points of view. Covers data representation, basic digital logic circuits, memory types and hierarchies, I/O and storage devices, CPU architectures such as RISC, CISC, parallel, and multi-core.

CMP SCI 2750 System Programming and Tools (3) Prerequisite: CMP SCI 2250. Covers systems programming, scripting, libraries, utilities, and development tools. Additional programming topics include piping, binary files, exception handling, command-line arguments and symbolic debugging. This course also explores tools available in the Unix/Linus environments.


This post was edited by Eep on Jan 22 2013 07:39pm
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 13 2013 09:16pm
Code
import java.util.Scanner;

public class Calendar {
   public static void main(String[] args) {
       
       int[] daysInMonth = new int[] {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
       String[] months = new String[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
       Scanner userIn = new Scanner(System.in);

       System.out.println("Please enter the first day of the year (1 for Monday, etc)");
       int userDay = userIn.nextInt();
       System.out.println("Please enter what year it is");
       int userYear = userIn.nextInt();
   
       printCalendar(userDay, userYear, months, daysInMonth);
       
       if (isLeapYear(userYear)) {
           System.out.println(userYear + " Was a leap year!");
       }
   
   }
   
   public static boolean isLeapYear(int year) {
       if (year % 4 != 0) {
           return false;
       } else if (year % 400 == 0) {
           return true;
       } else if (year % 100 == 0) {
           return false;
       } else {
           return true;
       }
   }
   
   public static void printCalendar(int day, int year, String[] months, int[] daysInMonth) {
       int startDay;
       
       for (int i = 0; i < months.length; i++) {
           System.out.println("\t" + months[i] + " " + year);
           System.out.println("____________________________");
           System.out.println(" " + "Sun" + " " + "Mon" + " " + "Tue" + " " + "Wed" + " " + "Thu" + " " + "Fri" + " " + "Sat");
           switch (day) {
              case 1: System.out.println("       " + "1" + "   " + "2" + "   " + "3" + "   " + "4" + "   " + "5" + "   " + "6" + "\n");
                  startDay = 7;
                  break;
              case 2: System.out.println("           " + "1" + "   " + "2" + "   " + "3" + "   " + "4" + "   " + "5" + "\n");
                  startDay = 6;
                  break;
              case 3: System.out.println("               " + "1" + "   " + "2" + "   " + "3" + "   " + "4" + "\n");
                  startDay = 5;
                  break;
              case 4: System.out.println("                   " + "1" + "   " + "2" + "   " + "3" + "\n");
                  startDay = 4;
                  break;
              case 5: System.out.println("                       " + "1" + "   " + "2" + "\n");
                 startDay = 3;
                 break;
              case 6: System.out.println("                           " + "1" + "\n");
                  startDay = 1;
                  break;
              default: System.out.println("   " + "1" + "   " + "2" + "   " + "3" + "   " + "4" + "   " + "5" + "   " + "6" + "   " + "7" + "\n");
                  startDay = 8;
                  break;
              }
              int k = daysInMonth[i];
              if (i == 1 && isLeapYear(year)) {
                  k = 29;
              }
              int count = 0;
              int currentDay = 0;
              for (int s = startDay; s <= k; s++) {
                  System.out.printf("%4d", s);
                  count++;
                  currentDay++;
                  if (count % 7 == 0) {
                      System.out.println("\r");
                  }
                  if (currentDay == 7 && s != k-1) {
                      currentDay = 0;
                  }
              }
              day = currentDay;
              System.out.println("\n");
             
          }
                 
                 
         }
                 
    }



one of the first projects I did. Easy stuff, we are just getting our feet wet w/ java syntax a little bit.

Took me longer than I wanted because I am still a horrible programmer.

if you find stupid and/or unnecessary shit, don't be surprised.

I hope I get better as time goes on. I don't like getting stuck on easy shit like this :/

This post was edited by Eep on Feb 13 2013 09:18pm
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 13 2013 09:34pm
i'd suggest a few things.

1. build a class to represent a month, and that month should know which day of the week is its 1st day and also how to format itself based on that
2. separate your presentation layer from your formatting, eg dont go directly to Syso
3. learn to log
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 13 2013 10:35pm
Quote (carteblanche @ Feb 13 2013 10:34pm)
i'd suggest a few things.

1. build a class to represent a month, and that month should know which day of the week is its 1st day and also how to format itself based on that
2. separate your presentation layer from your formatting, eg dont go directly to Syso
3. learn to log


how do classes work when using an IDE like netbeans?


Like you can include packages and libraries - however I am not sure on what a package is, I think I have seen that word used to represent more than 1 thing.


If I wanted a month class for example, and wanted to use it in my project, would I have to just make a regular class (without a main method) and then when I am building my project, use that month class as one of the packages included?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Feb 13 2013 11:52pm
since you didnt create a package, you're just using a default package. you can stick another class in there without having to import anything.

packages are just for organizational purposes to avoid naming conflicts. when you try to use List, do you want to use java.awt.List or java.util.List or org.eep.datastructure.List? they're also very useful for configuration, eg set logging to debug for org.eep.view.* but use info for org.eep.data.*, but you just created a new package org.eep.data.time.* so set that to trace for now.
Go Back To Programming & Development Topic List
Prev1161718192056Next
Add Reply New Topic New Poll