d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Make Me A Better Programmer - From Step 1
Prev1171819202156Next
Add Reply New Topic New Poll
Member
Posts: 4,541
Joined: Sep 15 2011
Gold: 10,391.00
Feb 14 2013 01:38pm
ew netbeans
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Feb 14 2013 03:21pm
Quote (Eep @ Feb 13 2013 11:35pm)
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?


1. Don't use Netbeans. Use IntelliJ IDEA or (ugh) Eclipse.
2. Packages are a form of namespacing in Java (http://en.wikipedia.org/wiki/Namespace_(computer_science)). You use them to logically group like classes and to hide things that are only relevant in the package.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 14 2013 03:46pm
Quote (rockonkenshin @ Feb 14 2013 04:21pm)
1. Don't use Netbeans. Use IntelliJ IDEA or (ugh) Eclipse.
2. Packages are a form of namespacing in Java (http://en.wikipedia.org/wiki/Namespace_(computer_science)). You use them to logically group like classes and to hide things that are only relevant in the package.


That is what a thought, a group of like classes. But usually not just a single class right?
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Feb 14 2013 08:23pm
Quote (Eep @ Feb 14 2013 04:46pm)
That is what a thought, a group of like classes. But usually not just a single class right?


Most of the time not, but it can if it makes sense for the class to be. Just like naming classes proper packing is an art and a science and sometimes is kind of difficult if you care about things like that (which you should).
Member
Posts: 35,454
Joined: Jan 25 2009
Gold: 1,173.00
Feb 15 2013 02:39am
Quote (rockonkenshin @ 14 Feb 2013 16:21)
1. Don't use Netbeans. Use IntelliJ IDEA or (ugh) Eclipse.
2. Packages are a form of namespacing in Java (http://en.wikipedia.org/wiki/Namespace_(computer_science)). You use them to logically group like classes and to hide things that are only relevant in the package.


I heard Eclipse was good. So what about Oracle and what not? I use JCreator just because that's what the school uses.
Member
Posts: 11,637
Joined: Feb 2 2004
Gold: 434.84
Feb 15 2013 08:37am
Quote (NinjaSushi2 @ Feb 15 2013 03:39am)
I heard Eclipse was good. So what about Oracle and what not? I use JCreator just because that's what the school uses.


People love Eclipse, don't get me wrong. I think they love it because they haven't tried to use and truly learn a competent IDE. I used Eclipse heavily for years until I started to get annoyed with all of it's fucking quirks. I switched to IntelliJ IDEA and one would have to drag me, kicking and screaming, back to Eclipse.

Use the tool that your school uses so you don't have to figure everything out by yourself. Once you get more knowledge you will realize that IDEs are more than just fancy text editors and that they can do things for you and your code that will save you hours. Once you get to the point where you feel held back by the editor start to learn something else but for a beginner anything is going to do the job.
Member
Posts: 35,454
Joined: Jan 25 2009
Gold: 1,173.00
Feb 15 2013 11:29am
Cool thanks.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Feb 19 2013 02:15am
Code
#!/usr/dt/bin/dtksh

#rst contains the user names from the roster file

rst=`cut -d ":" -f 1 /accounts/classes/(prof name)/c275/intro/roster`

#This is the first case. No args entered = we check to see if anyone from roster is logged on

if [ $# -eq 0 ]; then
   echo "No args entered, checking roster file..."
   for i in $rst; do
       finger | cut -c 1-6 | grep $i > /dev/null
       if [ $? -eq 0 ]; then
           echo "$i is on"
       fi
   done

#This is the second case. First checks to see if the arg entered is a valid user, then checks to see if they are online

else
   for i; do
       id $i > /dev/null
       if [ $? -eq 0 ]; then
           finger | cut -c 1-6 | grep $i > /dev/null
           if [ $? -eq 0 ]; then
               echo "$i is on"
           fi
       else
           echo "$i is not a user"
       fi
   done
fi


First ksh script I had to write for a different class. Sadly only knew about 10% from the lectures (prof isn't the best), had to look the other 90% up but I learned a lot along the way.

This post was edited by Eep on Feb 19 2013 02:16am
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 13 2013 06:50pm
another script, still probably more complicated than it needs to be

Code
#This script is intended to alert the user when anyone from a list of users (args to the script) is online on admiral.
#The script optionally accepts a message to be sent to the user when someone is by utilizing the -m option.
#The script optionally accepts a date to run the script at. However there is a limitation due to at jobs not working correctly at the moment (outlined below)
#The date arg entered must be in the form of something like: TueMar121200 (DayMonDay#Time#)
#The correct execution of the script would ideally run it using '&' to run it in the background, perhaps nohup to let it run while logged off admiral.

USAGE="Correct usage: alert -w [optional date] -m [optional message] [user list]"

if [ $# -lt 1 ]; then
   echo "Must enter at least 1 user to search for" && exit 1
fi

while getopts w:m: var
do
   case $var in
   w)      wflag=1
           wval="$OPTARG";;
   m)      mflag=1
           mval="$OPTARG";;
   ?)      echo $USAGE && exit 0
   esac
done

shift $(($OPTIND -1))

if [ ! -z "wflag" ]; then
   while ( sleep 60 ); do
       time=`date | awk -F" " '{print $1 $2 $3 $4}' | awk -F":" '{print $1 $2}' | sed "s/://g"`
       if [ $time -eq "$wval" ]; then
           break
       fi
   done
fi

while ( sleep 66 ); do
   for i; do
       id $i > /dev/null
       if [ $? -eq 0 ]; then
           finger | grep ^$i > /dev/null
           if [ $? -eq 0 ]; then
               finger | grep ^$USER
               if [ $? -eq 0 ]; then
                   banner $i IS ON
                   if [ ! -z "$mflag" ]; then
                       echo "$mval" | write $USER
                   fi
               else banner "$i IS ON" | elm -s $mval $USER
               fi
               if [ $# -eq 1 ]; then
                   exit 0
               fi
               set $(echo $@ | sed "s/$i//")
           fi
       else echo "$i is not a user. Please re-run the script with a correct user name [Consider searching for the username with the id command]" && echo "\n$USAGE" && exit 0
       fi
   done
done
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Mar 21 2013 03:44pm
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


I know this was an old post of yours but I have some questions

what did you mean in 2. Could you give an example? (I know you said not to go directly to syso but how else would you do it)

Also, where is a good resource to learn about logging (such as when/where/how to utilize it)

This post was edited by Eep on Mar 21 2013 03:44pm
Go Back To Programming & Development Topic List
Prev1171819202156Next
Add Reply New Topic New Poll