• 0

[java] kalender help needed


Question

hello ppl,

i have to make a kalender for school but iam stuck.

i hope some 1 can make the thing complete:)

it is pretty simple but i suck@ programming so:D

it has to look like this:

month: [ <input for a number to set the month> ] year: [ <input for the year>] [button] ( this will start calculating)

mo tu we th fr sa su

1 2 3 4 5 6 7

. . .

but if the first day of the month start on a sunday 1 has to be under sunday. u get the idea.

can some 1 make that for me?

i have already something to start with but i can't finish it:S

import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class Datum2 extends Applet 
{

TextField D, M;
Button B;
Label maand, jaar;


	public void init() 
	{
  D = new TextField( 10 );
  M = new TextField( 10 );
  
  B = new Button ("Bereken");
  B.addActionListener( new KnopHandler() );
  
  maand = new Label ("Maand:");
  jaar = new Label ("Jaar:");
  
  add ( maand );
  add ( D );
  add ( jaar );
  add ( M );
  add ( B );
	}

	public void paint(Graphics g) 
	{
  g.drawString(" Za  Zo  Ma  Di  Wo  Do  Vr", 50, 100);
  
  int regel = 0;
  
  for( int dag = 1; dag&lt;=31; )
  {
 	 SchrijfRegel(g,regel,dag,aantalDagen);
 	 dag +=7;regel++;
  }
	}

 String mnd = "";  // stelt et aantal maanden in
       switch (this.maand)
        {
             case 1: mnd = "Januari"; break;
             case 2: mnd = "Februari"; break;
             case 3: mnd = "Maart"; break;
             case 4: mnd = "April"; break;
             case 5: mnd = "mei"; break;
             case 6: mnd = "Juni"; break;
             case 7: mnd = "Juli"; break;
             case 8: mnd = "Augustus"; break; 
             case 9: mnd = "September"; break;
             case 10: mnd = "Oktober"; break;
             case 11: mnd = "November"; break;
             case 12: mnd = "December"; break;
             return mnd;
              
int aantalDagen;
        switch (this.maand)
        {         	 //aantal dagen van de maand instellen
                case 1: aantalDagen = 31;break;
                case 2: aantalDagen = 28;break;
                case 3: aantalDagen = 31;break;
                case 4: aantalDagen = 30;break;
                case 5: aantalDagen = 31;break;
                case 6: aantalDagen = 30;break;
                case 7: aantalDagen = 31;break;
                case 8: aantalDagen = 30;break;
                case 9: aantalDagen = 31;break;
                case 10: aantalDagen = 30;break;
                case 11: aantalDagen = 31;break;
                case 12: aantalDagen = 30;break;
                


	void SchrijfRegel( Graphics g, int regel, int dag, int max)
	{
  for(int i=0; i&lt;7;i++)
   if((dag+i)&lt;=max)
      g.drawString(""+(dag+i),50+i*20,120+regel*20);
	}
    
	class KnopHandler implements ActionListener
	{
  public void actionPerformed ( ActionEvent e )
  {
 	 String t1 = D.getText();
 	 int D = Integer.parseInt( t1 );
 	 
 	 String t2 = M.getText();
 	 int M = Integer.parseInt( t2 );
  
 	 repaint();
  }
	}

    
}

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

couldnt find a decent 1 there:S

it is exually for school so:D

iam really happy if some 1 can fix the prob because i can't . i ****** up enough time this week just for this stuff:S

Link to comment
Share on other sites

  • 0

hmmmm.... I am not going to do it for you...

You say that you are stuck but don't say on what.

My Input: Where I go to school unauthorized aid on assignments results in a minimum F in the course... usually a 2 semester suspension. If you do your own work then you will find it both more rewarding and more intellectually valuable. If your assignment is to write a calendar than you should write a calendar. The assignment is not to find out how you can get other people to write a calendar for you.

Link to comment
Share on other sites

  • 0

Oh, and one more question. Who decides whether the first day of the month falls under which weekday? Because if you want to make it an accurate calendar then you have to check a real calendar for info and you are not doing that. I mean lets say i enter month 6 of the year 2017, how the heck will you know how will the days fall on that month? You can start counting from now until then but even then you have to check the current date. But it will be too slow.

Meh....more info needed. :whistle:

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.