dimasalang's Profile User Rating: -----

Reputation: 2 Apprentice
Group:
New Members
Active Posts:
4 (0.01 per day)
Joined:
02-October 12
Profile Views:
200
Last Active:
User is offline Oct 16 2012 11:28 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   dimasalang has not set their status

Posts I've Made

  1. In Topic: Problems with Student.java code and how to test

    Posted 3 Oct 2012

    you've got a lot of errors here.

    First: Line 16: I don't know if that's a method or a variable. I think it's a method since you have a return statement at line 17. Lines 16 to 18 should be like this
    public int qTaken(){
    	return (int) numQuizzesTaken;
    	}
    


    all your methods are incorrectly declared. They should be like this:
    public String methodName(){
        return "Sample String";
    }
    
    

    Do note that Java is case sensitive.

    Also you cannot call the System.out.println outside a method. :bananaman:
  2. In Topic: Time class confusion!

    Posted 3 Oct 2012

    Hi. I don't know if that will work in terms of testing your Time class. But I guess it should be something like this
    instantiate Time using Time(hour, minute) as t
    
    // or get input from user for hour and minute
    instantiate Time using Time() as t
    
    Ask minute from user
    t.setMinute(minute given by user)
    
    Ask hour from user
    t.setHour(hour given by user)
    
    Ask user if he wants to add ten minutes
    if yes call the addTen method
    if no do nothing
    
    Ask user if he wants to subtract ten minutes
    if yes call the subtractTen method
    if no do nothing
    


    Code wise, you have some syntax errors. Like this one, your while loop is outside your main method. I think it won't work. youd should place it inside the main method(Lines from 12 to 36). And there are some ';' that may cause errors like the ones in Line 18 and 29. And some missing curly braces.
    I have tried to correct it and come up with something like this:
    import cs1.Keyboard;
    
    public class TestTime
    {
    	public static boolean main (String[] args)
    	{
    		Object t1 = new Object();
    		Object t2 = new Object();
    		Boolean b = new Boolean(true);
    		while (b = true){
    		System.out.println(Time);
    		System.out.println("Would you like to add ten seconds to the time?");
    			Keyboard.readBoolean();
    		}
    		if(b = true){//;
    			Time.addTen();
    			System.out.println("It is now" + Time.addTen);
    		}else{
    			System.out.println("The time is" + Time);
    		}
    		System.out.println("Would you like to subtract ten seconds from the time?");
    		Keyboard.readBoolean();
    			
    		if(b = true){//;
    			Time.subtractTen();
    			System.out.println("It is now" + Time.subtractTen);
    		}
    		//{
    		else{
    				System.out.println("The time is" + Time);
    		}
    	}
    
    	
    }
    

    :bigsmile: hope this helps.
  3. In Topic: Time class confusion!

    Posted 3 Oct 2012

    Hi. I think it would throw an error. It's better to define your printTime() method outside your constructor. Also, define setter and getter for your hour and minutes variables. :)
  4. In Topic: Understanding nextLine().

    Posted 2 Oct 2012

    Hi there. Yes your understanding is correct. According to oracle's documentation

    Quote

    nextLine() Advances this scanner past the current line and returns the input that was skipped.


    nextLine() can be used when you're reading Strings from a text file with multiple line of texts.

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

dimasalang hasn't added any friends yet.

Comments

Page 1 of 1
  1. Photo

    fromTheSprawl Icon

    02 Oct 2012 - 22:49
    Yo, where are you from? :)
Page 1 of 1