Glorfindal's Profile User Rating: -----

Reputation: 30 Craftsman
Group:
Contributors
Active Posts:
563 (0.26 per day)
Joined:
31-December 08
Profile Views:
17,708
Last Active:
User is offline Dec 07 2014 09:11 PM
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Linux
Favorite Browser:
FireFox
Favorite Processor:
Intel
Favorite Gaming Platform:
XBox
Your Car:
Who Cares
Dream Kudos:
225

Latest Visitors

Icon   Glorfindal is currently writing a game with ASP and Microsoft Access (Database) called Dragon Craft

Posts I've Made

  1. In Topic: [games design] openGL

    Posted 9 Nov 2014

    Unfortunately, I don't have any books to recommend for you, but there is a really good series of tutorials on the topic on YouTube. The guy who is doing the series is still making more episodes and does a very good job explaining the reasons for things which means it would be pretty easy for you to learn the core concepts and do something different on your own. His channel and videos are pretty unknown and he deserves a lot more attention. Here's a link to the first episode in the series.

    https://www.youtube....h?v=VS8wlS9hF8E

    As of writing this there are currently 18 videos in the series and a new one comes out every Saturday. Hopefully this should be enough to help get you started. :)
  2. In Topic: Dealing with For Loops

    Posted 5 Nov 2014

    I fixed up your code. You had the right idea it was really just a few syntax errors and duplicate line problems. Some things to note. You do not put semi-colons after if-statements, also if an if statement only has one instruction in it you do not need to use curly braces, however if there is more than one line of code that is executed they are required. There may be times though in which there will only be one line of executable code inside an if-statement, but you will still need to use curly braces, for example in if-else statements. Hopefully this helps you, you seem to be doing well with the concepts you just need to work on your syntax. :)

    public class Lab6
    {
            public static void main(String[] args)
            {
    
            java.util.Scanner input = new java.util.Scanner(System.in);
            int i;
            int sum=0;
            int gradeA = 0;
            int gradeB= 0;
            int gradeC= 0;
            int gradeD= 0;
            int gradeF= 0;
            double avg;
            System.out.print("Enter number of Students in the Class: ");
            int n = input.nextInt();
            for (i=1; i<=n; i++)
            {
                    System.out.print("Enter an Exam Score: ");
                    int score = input.nextInt();
    
                    if(score >= 90) gradeA++;
    
                    if(score >= 80 && score < 90) gradeB++;
    
                    if(score >= 70 && score < 80) gradeC++;
    
                    if(score >= 60 && score < 70) gradeD++;
    
                    if(score < 60) gradeD++;
              
                    sum = sum+score;
    
            }
            avg = (double)sum/n;
            System.out.println("The Average Exam Score Is: " + avg);
            System.out.println(gradeA);
            System.out.println(gradeB);
            System.out.println(gradeC);
            System.out.println(gradeD);
            System.out.println(gradeF);
            }
    }
    
    
    
  3. In Topic: build a fan in java

    Posted 5 Nov 2014

    You need a timer that runs all the time and action listeners for the buttons. Inside of that timer you need to check if the fan is on and update it's position if it is and then it needs to redraw the screen. You can redraw the screen by calling the repaint() method. I did some of the code to help get you started but it is up to you to finish it. The below code runs a timer every 50ms (20 times a second) that updates the fan blade position if it the fan is turned on then redraws the screen. I'll let you implement the fan speeds yourself. :)/>
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.*;
    public class Fan extends JFrame implements ActionListener {
    	
    	public static boolean fanOn = false;
    	public static int offSetFanBlades = 0;
    	
    	Fan()
    	{
    		setLayout(new BorderLayout());
    		Blades blades=new Blades();
    		JPanel controls=new JPanel();
    		JButton onoff = new JButton("ON/OFF");
    		onoff.addActionListener(this);
    		controls.setLayout(new FlowLayout(FlowLayout.LEFT,10,10));
    		controls.add(onoff);
    		controls.add(new JButton("SLOW"));
    		controls.add(new JButton("MEDIUM"));
    		controls.add(new JButton("FAST"));
    		add(blades,BorderLayout.CENTER);
    		add(controls,BorderLayout.SOUTH);
    	}
    
    	public static void main(String[] args)
    	{
    		Fan fan=new Fan();
    		fan.setTitle("NYCCT FAN");
    		fan.setSize(500,500);
    		fan.setLocationRelativeTo(null);
    		fan.setDefaultCloseOperation(EXIT_ON_CLOSE);
    		fan.setVisible(true); 
    	}
    
    	@Override
    	public void actionPerformed(ActionEvent event) {
    		System.out.println("Fan toggled");
    		if(Fan.fanOn) {
    			Fan.fanOn = false;
    		} else {
    			Fan.fanOn = true;
    		}
    	} 
    }
    
    class Blades extends JPanel implements ActionListener {
    	
    	Blades() {
    		Timer timer = new Timer(50, this);
    		timer.start();
    	}
    	
    	protected void paintComponent(Graphics g){
    		super.paintComponent(g);
    
    		int w=getWidth();
    		int h=getHeight();
    		int noOfBlades=5;
    		g.setColor(Color.BLUE);
    		g.fillOval(20, 20, w-40, h-40);
    		g.setColor(Color.RED);
    		for(int i=0;i<noOfBlades;i++)
    		g.fillArc(20,20,w-40,h-40,(int)(i*360./noOfBlades) + Fan.offSetFanBlades,(int)(360./(noOfBlades*3)));
    		g.drawString("Fan Blades: " + Fan.offSetFanBlades, 10, 10);
    	}
    	
    	@Override
    	public void actionPerformed(ActionEvent arg0) {;
    		if(Fan.fanOn) {
    			if(Fan.offSetFanBlades == 360) {
    				Fan.offSetFanBlades = 0;
    			} else {
    				Fan.offSetFanBlades = Fan.offSetFanBlades + 5;
    			}
    			System.out.println("Fan Blades: " + Fan.offSetFanBlades);
    		}
    		repaint();
    	}
    }
    

    Also I took the liberty of fixing the indentions and adding some print line statements in your code. Hopefully that should make debugging it later easier.
  4. In Topic: How do tenure awards work?

    Posted 5 Nov 2014

    Okay that clears it up. Then I'll take the other years if it isn't too much work for you.
  5. In Topic: ATM / Bitcoin

    Posted 5 Nov 2014

    Can you post the code you have so far and maybe the full assignment description? I think I would be able to understand what you need to do better if provided with that. :)

My Information

Member Title:
Java Enthusiast
Age:
Age Unknown
Birthday:
July 20
Gender:
Interests:
Playing Games, Creating Games, Playing Heroes of Ardania, Working on my Website, Hanging out with my friends and Playing Soccer
Years Programming:
5
Programming Languages:
HTML5, CSS, C++, Javascript, Classic ASP, PHP, Java

Contact Information

E-mail:
Private
Website URL:
Website URL  http://www.richardsprojects.net

Comments

Page 1 of 1
  1. Photo

    fromTheSprawl Icon

    06 Nov 2014 - 00:12
    Hey pal, how are you
  2. Photo

    fromTheSprawl Icon

    07 Jul 2013 - 19:37
    Dude! How is the game?
  3. Photo

    fromTheSprawl Icon

    13 Aug 2012 - 19:44
    Hey dude, glad to know you're still around. ^^
  4. Photo

    111027 Icon

    05 Jan 2012 - 15:30
    Haven't seen you around, mate.
  5. Photo

    fromTheSprawl Icon

    30 Nov 2011 - 19:21
    Hey there dude! How's things? The project? You can do it! ^^
  6. Photo

    Guest 

    29 Jun 2010 - 13:56
    http://www.dreamincode.net/forums/topic/179550-updatepanels-placeholders-and-usercontrols/
  7. Photo

    Glorfindal Icon

    06 May 2010 - 14:20
    what do you want the signature to say?
  8. Photo

    williamgeorgegardner Icon

    17 Feb 2010 - 11:39
    Can you do me one of those signatures just email me @ will@williamgardner.co.uk
Page 1 of 1