Violet_82 89 Posting Whiz in Training

Hi all, my parents have just opened their xmas present, brand new dell 5520 laptop. I have plugged the ac adapter in to get it charged and noticed that the battery led light on the actuall laptop is off. I am fairly sure the charger works because the light on the charger is on as it should, it's just the corresponding led on the actual laptop that's off, and I was wondering if this is normal or not...is it a new windows 8 thingy? From memory any lappy I have ever had, when you plug the adapter in the led light goes on.
any idea?
thanks

Violet_82 89 Posting Whiz in Training

that's fine thanks, I guess I will learn with practice. Also, what confused me a bit about the above program was the fact that the setters are there but are not used, but we've discussed a similar issue in a previous post (the setters are just there as an example)

Violet_82 89 Posting Whiz in Training

thanks for the post.
Sorry if I will say something obvious, but being a beginner I still have quite a lot to learn. Now, in your post amirbwb I guess it makes sense to have a constructor Person(String firstName,String lastName,int age){ rather than a setter public void setFirstName(String firstName). From your code I seem to understand that the purpose of a constructor is only to initialize variables, nothing else. So the advantage of using a constructor over a setter is that a constructor can initialize more than a variable, which is what a setter does?

It's generally classed as good or maintainable programming to initialise all global variables in the constructor rather than wait for them to be set using setters.

I thought the point of a setter was to initialize variables...

Violet_82 89 Posting Whiz in Training

HI peeps,
I have a question about the following program:

TempScale.java:

public enum TempScale {
    CELSIUS, FAHRENHEIT, KELVIN, RANKINE,
    NEWTON, DELISLE, R�AUMUR, R�MER, LEIDEN 
};    

Temperature.java

public class Temperature {
    private double number;

    private TempScale scale;

    public Temperature() {
        number = 0.0;
        scale = TempScale.FAHRENHEIT;
    }

    public Temperature(double number) {
        this.number = number;
        scale = TempScale.FAHRENHEIT;
    }

    public Temperature(TempScale scale) {
        number = 0.0;
        this.scale = scale;
    }

    public Temperature(double number, TempScale scale) {
        this.number = number;
        this.scale = scale;
    }

    public void setNumber(double number) {
        this.number = number;
    }

    public double getNumber() {
        return number;
    }

    public void setScale(TempScale scale) {
        this.scale = scale;
    }

    public TempScale getScale() {
        return scale;
    }
}

UseTemperature.java

import static java.lang.System.out;

class UseTemperature {

   public static void main(String args[]) {
       final String format = "%5.2f degrees %s\n";

       Temperature temp = new Temperature();
       temp.setNumber(70.0);
       temp.setScale(TempScale.FAHRENHEIT);
       out.printf(format, temp.getNumber(), 
                          temp.getScale());

       temp = new Temperature(32.0);
       out.printf(format, temp.getNumber(), 
                          temp.getScale());

       temp = new Temperature(TempScale.CELSIUS);
       out.printf(format, temp.getNumber(), 
                          temp.getScale());

       temp = new Temperature(2.73, TempScale.KELVIN);
       out.printf(format, temp.getNumber(), 
                          temp.getScale());
   }
}

Now, the way the program works is fairly clear, but what I don't understand is why they use constructors...what's the point of that? My understanding is that everytime a new object is called, then the "equivalent" constructor is called and the values assigned to the variables: like when this statement executes Temperature temp = new Temperature(); then this constructor gets called

public Temperature(){
        number = 0.0;
        scale = TempScale.FAHRENHEIT;
    }

So as mentioned, …

Violet_82 89 Posting Whiz in Training

Ok fair enough, thank you all for your contributions!

Violet_82 89 Posting Whiz in Training

I'd agree with you T-Dogg3030 if it was a big big piece of code, but what's the point of doing that in such a small program? I thought he did it becasue it was actually doing something, but it isn't really

Violet_82 89 Posting Whiz in Training

fantastic, thanks for that, much clearer now!!

Violet_82 89 Posting Whiz in Training

Hi I am trying to give some sense to this expression

#container, #footer {
    width: expression(document.body.clientWidth < 742? "740px" : document.body.clientWidth > 1202? "1200px" : "auto");
    }

found on here http://www.cameronmoll.com/archives/000892.html
but I can't quite get it. Is it saying if the width of the page is less than 745 then resize it to 740 or if it is more than 1202 then resize it to 1200? But what about that auto at the end of it? I guess it's not the same as a normal if statement, any idea please?
thanks

Violet_82 89 Posting Whiz in Training

thanks, that's the whole program actually (the employee class and the main class) that's why I am a bit baffled

Violet_82 89 Posting Whiz in Training

thanks for the comments guys, really helps. One more question though: if the getters are not used, what's the point of having them in the program? I appreciate it's good programming practice, but they are just a waste of code if not used aren't they?

Violet_82 89 Posting Whiz in Training

no I am happy for it to pick up the fastest, the wired will always invariably faster so I am happy with that. It's that it seems to good to be true : - )

Violet_82 89 Posting Whiz in Training

I would have thought that windows stick to the default, meaning, if the default is the wireless then even if you plug the cable in it will use the wireless.

Violet_82 89 Posting Whiz in Training

Hi there, quick question. Say my laptop is connected to a wireless network, and I then decide to plug the wire in, does the wired connection takes over? In other words with both the wireless and the wired cable connected, which one take precedence?
thanks

Violet_82 89 Posting Whiz in Training

HI all, I was looking at this program and noticed few things:

import static java.lang.System.out;

public class Employee {
    private String name;
    private String jobTitle;

    public void setName(String nameIn) {
        name = nameIn;
    }

    public String getName() {
        return name;
    }

    public void setJobTitle(String jobTitleIn) {
        jobTitle = jobTitleIn;
    }

    public String getJobTitle() {
        return jobTitle;
    }

    public void cutCheck(double amountPaid) {
        out.printf("Pay to the order of %s ", name);
        out.printf("(%s) ***$", jobTitle);
        out.printf("%,.2f\n", amountPaid);
    }
}




import java.util.Scanner;
import java.io.File;
import java.io.IOException;

class DoPayroll {

    public static void main(String args[])
                                  throws IOException {
        Scanner diskScanner =
            new Scanner(new File("EmployeeInfo.txt"));

        for (int empNum = 1; empNum <= 3; empNum++) {
            payOneEmployee(diskScanner);
        }
    }

    static void payOneEmployee(Scanner aScanner) {
        Employee anEmployee = new Employee();

        anEmployee.setName(aScanner.nextLine());
        anEmployee.setJobTitle(aScanner.nextLine());
        anEmployee.cutCheck(aScanner.nextDouble());
        aScanner.nextLine();
    }
}

And here's the text file

Barry Burd
CEO
5000.00
Harriet Ritter
Captain
7000.00
Your Name Here
Honorary Exec of the Day
10000.00

Right, so first thing: where are the calls to the getters? Surely they are implicitly called, but how? I don't see anywhere

getName()

and

getJobTitle()

?
And don't we need a third setter and getter for the thrid variable, the money?
Then the for loop:

for (int empNum = 1; empNum <= 3; empNum++) {
            payOneEmployee(diskScanner);
        }

We are running this loop 3 times because eachinstance of the new Employee class created has 3 variables associated with it (name, jobTitle and the money?)

thanks

Violet_82 89 Posting Whiz in Training

I have a working example here, the code is different from what I have posted but it replicates the issue. If you look at it in IE7 and 8 the background image shouldn't be there:
http://antobbo.webspace.virginmedia.com/various_tests/gradient/test.htm

Violet_82 89 Posting Whiz in Training

I have now pritaeas, I have just tried a .gif and as I suspected it made no difference. The problem is in the css, IE7 and 8 do't seem to like the fallback, so there must be, I am sure, another way to make ie7 and 8 to behave, ie, to get the background image to display.
thanks

Violet_82 89 Posting Whiz in Training

thanks, interesting tools. I used a similar one that tells you which browser supports the gradients. My question though is why are IE7 and 8 not displaying any image at all even if I have what I think is a fallback in my css:

...
 background: url("image.png");
 ...
 background-position:100% 60%;
background-repeat:no-repeat;

I mean if a browser can't understand this line background-image: url("image.png"), linear-gradient(to top, #F3F4F4 0%, #FFFFFF 100%); then surely the above should be used as a fall back and the image should be displayed anyway?!

Violet_82 89 Posting Whiz in Training

fab, thanks

Violet_82 89 Posting Whiz in Training

thanks, is there a guide somewhere on how to do that with the command prompt (I use linux)?
Also, the deitel and deitel book you recommended, is it easy to understand even for somebody who has never done any coding before?
thanks

Violet_82 89 Posting Whiz in Training

thanks guys that really helps!

Violet_82 89 Posting Whiz in Training

ok fab, thanks a lot for your help

Violet_82 89 Posting Whiz in Training

thanks, that's useful! So, just so i get this right, you're suggesting to add all those classes to my custom css correct?
cheers

Violet_82 89 Posting Whiz in Training

thanks, I have a manual already, I was more looking for exercises like "build a program that produces such and such output", still for beginners of course
thanks

Violet_82 89 Posting Whiz in Training

Thanks, your link does help quite a bit.
I have now produced this:

#myDiv{
    /*border:1px solid green;*/
    /*width:940px;*/
    padding:10px 0 0 20px;
    height:160px;
    background: url("image.png");
    border:1px solid #d4d1c8;

        /* IE10 Consumer Preview */ 
background-image:url("image.png"), -ms-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);
/* Mozilla Firefox */ 
background-image: url("image.png"), -moz-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);
/* Opera */ 
background-image:url("image.png"), -o-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);
/* Webkit (Safari/Chrome 10) */ 
background-image: url("image.png"), -webkit-gradient(linear, left bottom, left top, color-stop(0, #F3F4F4), color-stop(1, #FFFFFF));
/* Webkit (Chrome 11+) */ 
background-image: url("image.png"), -webkit-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);
/* W3C Markup, IE10 Release Preview */ 
background-image: url("image.png"), linear-gradient(to top, #F3F4F4 0%, #FFFFFF 100%);

background-position:100% 60%;
background-repeat:no-repeat;
    }

So in other words, I have managed to squeeze in the background repeat and the background position. All good if it wasn't for IE7 and IE8 that don't show the background image for whatever reason. I kind of expect that therefore I purposely left this line at the top background: url("image.png") thinking I could use it as fallback in case a browser doesn't support what seems to be effectively a double background image.
Any idea?
thanks

Violet_82 89 Posting Whiz in Training

Well it looks like it is possible, this line actually works background-image: url("image.png"), -moz-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%); and display the background image,the only thing is that I can't position the image correctly in the div

Violet_82 89 Posting Whiz in Training

hi thanks all. gavinflud, can a label tag have an id? Sorry it didn't occur to me!

@Baradaran, no it's just one lable

@orgeM yes I include jquery in my project but I just wanted to use as much css as possible that's why I didn't want to use jquery to achieve this

Violet_82 89 Posting Whiz in Training

Hi there, I have a bit of a problem here. I have a div with a background image positioned and I want to add a gradient background to this div

<div id="myDiv">
...
</div>

CSS:

#myDiv{
    /*border:1px solid green;*/
    /*width:940px;*/
    padding:10px 0 0 20px;
    height:160px;
    background:#fafafa url("image.png") no-repeat 100% 60%;
    border:1px solid #d4d1c8;
    }

Right, I have generated my background gradient using this very interesting resource http://ie.microsoft.com/testdrive/Graphics/CSSGradientBackgroundMaker/Default.html and come up with the following code to integrate into my css:

/* IE10 Consumer Preview */ 
background-image: -ms-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Mozilla Firefox */ 
background-image: -moz-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Opera */ 
background-image: -o-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Webkit (Safari/Chrome 10) */ 
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #F3F4F4), color-stop(1, #FFFFFF));

/* Webkit (Chrome 11+) */ 
background-image: -webkit-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* W3C Markup, IE10 Release Preview */ 
background-image: linear-gradient(to top, #F3F4F4 0%, #FFFFFF 100%);

After having read a bit on the net, it seems that you can combine background images and background gradients, so I came up with this:

#myDiv{
    /*border:1px solid green;*/
    /*width:940px;*/
    padding:10px 0 0 20px;
    height:160px;
    /*background: url("image.png") no-repeat 100% 60%;*/
    border:1px solid #d4d1c8;
        /* IE10 Consumer Preview */ 
background-image: -ms-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Mozilla Firefox */ 
background-image: url("image.png"), -moz-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Opera */ 
background-image:url("image.png"), -o-linear-gradient(bottom, #F3F4F4 0%, #FFFFFF 100%);

/* Webkit (Safari/Chrome 10) */ 
background-image: url("image.png"), -webkit-gradient(linear, left bottom, left top, color-stop(0, #F3F4F4), color-stop(1, #FFFFFF));

/* Webkit …
Violet_82 89 Posting Whiz in Training

no I was hoping to keep it in the css to be honest, that's why I didn't use jquery : - )

Violet_82 89 Posting Whiz in Training

Hi there, as I am learning java (providing I will have the time to keep going!) I was wondering if there is anywhere I can find some simple exercises to practice with. At the moment, as an introduction, I am reading a java for dummies book, so I am still doing very basic stuff, just got to "classes" today. Is there anywhere I can find anything to practice with? Ideally something with solutions and solutions explanation if I get really lost.
thanks

eldgeel11 commented: calculater +0
Violet_82 89 Posting Whiz in Training

quick question.Take this html

<form id="the_form">
    <input type="checkbox" value="ideal" name="ideal_drive"  id="ideal"><label for="ideal">This is a test only only</label><br>
...

Say I want to select the text in the label and give it a different colour. I tried this rule

#the_form label[for='ideal']{
    color:yellow;
}

It works ok but not in IE7. SO, I was thinking to use the :first-child selector:

#the_form label:first-child{
    color:yellow;
}

but it doesn't work at all.

Any idea what I can use to make sure it works on every browser?
thanks

Violet_82 89 Posting Whiz in Training

thanks gavinflud. As per giving ids and classes to your elements, yes totally agree with you but it is a bit difficult, at least for me that I have used wordpress once, to 1)determine where worpress inserts his own classes, I mean, it happened with images, and somebody else said on paragraphs as well, and 2)what the classes do to the element. So you will have to see first what the added worpress class does to the element to then cook up a rule to neutralize it. Take my image in the code above: it doesn't have an id because I really didn't need it there, but having seen that the wordpress adds a border to it, then I will have to add an id to it and have border:none; to override the wordpress class, or just delete the added class - eh eh once I know how to do it is is quite easy - from the advanced property. I don't know, but to me it seems unnecessary to have all these added classes.

thanks

Violet_82 89 Posting Whiz in Training

thanks, that's really awful, if I had known that beforehands I wouldn't have chose wordpress to be honest. ANyway, it seems that removing the unwanted classes from the advanced properties works ok too, so might stick to it for now, it might be easier for my friend to implement
Also strange that on the wordpress forum nobody was capable of telling me that, I don't mean to slag them off of course, but I very disappointed to be honest
cheers

Violet_82 89 Posting Whiz in Training

yes it is fine, I had troubles inserting the class without main in the structure somewhere not having done it before. So it looks like when I start a new project the first class that gets added is the one with a main method then, if I right click on package I can add a new class (and this by default has no main method). Then the program runs ok and compiles. I was more interested in the order you do things: the book I am reading said to add the class without main first then the other one, but I found that the first class added to a project has a main method, so it will have to come first. I think this was what confused me
thanks

Violet_82 89 Posting Whiz in Training

ok thank you

Violet_82 89 Posting Whiz in Training

I managed to get the model, it's a dell inspiron 5520. I was thinking about the 3520, but the former has a better processor

Violet_82 89 Posting Whiz in Training

ah, thanks, I tried to remove the border, went to the advanced tab as you said but there is no border. What I found though is that there is a "class name" field which has "alignnone size-full wp-image-334" in it: I removed that and left it empty and the border is gone!! Darn wordpress!!! I wonder if wordpress keeps adding classes everywhere when switching from visual to html view...

Violet_82 89 Posting Whiz in Training

Hi I am having problems running and compiling a program with more than one class, but I am not sure how to do it in netbean, it keeps complaining. I have the 2 following files called respectively Account.java

public class Account {
    String name;
    String address;
    double balance;
}

and UseAccount.java

import static java.lang.System.out;

class UseAccount {

    public static void main(String args[]) {
        Account myAccount;
        Account yourAccount;

        myAccount = new Account();
        yourAccount = new Account();

        myAccount.name = "Barry Burd";
        myAccount.address = "222 Cyberspace Lane";
        myAccount.balance = 24.02;

        yourAccount.name = "Jane Q. Public";
        yourAccount.address = "111 Consumer Street";
        yourAccount.balance = 55.63;

        out.print(myAccount.name);
        out.print(" (");
        out.print(myAccount.address);
        out.print(") has $");
        out.print(myAccount.balance);
        out.println();

        out.print(yourAccount.name);
        out.print(" (");
        out.print(yourAccount.address);
        out.print(") has $");
        out.print(yourAccount.balance);
    }
}

With simple programs - one class only - I usually go FIle, New Project, select Java under categories and java application under Project, that's all. SO, in the case above I would have UseAccount.java as main class but then I don't know where to put the second one.
thanks

Violet_82 89 Posting Whiz in Training

HI all, quick questiona bout a laptop I would like to buy for my parents, a dell 15, i3 processor, 4gb ram and windows 8.
Now, I have absolutely no experience at all with wondows 8 and I was wondering if anybody can let me know whether it is worth buying the laptop or not, if 4gb ram is enough for windows 8 to run smoothly etc. One more thing, my parents are used to windows vista, whether that's a good thing or not it doesn't matter really, so I wonder how different is window 8 from vista?
Here's the laptop spec where you can get an idea http://www.techdesigns.co.uk/dell-inspiron-15-review/ although it has windows 8 and not 7
thanks

Violet_82 89 Posting Whiz in Training

EvolutionFallen, really? Is it a bug in wordpress? Uhm, I didn't know that. It will be a bit of a problem to stick to one one "view" only because I created the website using the html view panel and my friend - who knows nothing about html - will use the visual view to update it. I guess I will have to explain him how to copy, paste and change the html. It's a shame there is absolutely nothing about this bug anywhere. Now, let me ask you then, does this happen only with images or with other things as well? Say I have a page where my friend whants to add some videos, are they going to end up with a border as well?

Violet_82 89 Posting Whiz in Training

thanks guys, it did work eventually, not sure why I was getting undefined, I deleted the code and started again, it all worked thanks for your help as usual

Violet_82 89 Posting Whiz in Training

thanks isn't there any way I can make use of that variable $allImages at all? the above line is returning undefined for whatever reason

Violet_82 89 Posting Whiz in Training

Hi I got in a bit of a muddle here. Basically say you have this html:

...
<a href="javascript:void(0)">
    <img alt="" data-name="myCar" data-family="ferrari" data-type="Fast Family" src="images/ferrari.png" style="left: 193.291px; opacity: 0.5; cursor: default;">    
</a>
<a href="javascript:void(0)">
    <img alt="" data-name="yourCar" data-family="aston" data-type="Fast Family" src="images/aston.png" style="left: 293.291px; opacity: 0.5; cursor: default;">    
</a>
...

In my script, there is a variable$allImages = $("a img"); containing all the images and I want to select exactly the element whose data-name attribute value is myCar and find its position - mind there are many more cars in the list.
So what I have tried first is this:
var theCar = $allImages.attr('[data-name="myCar"]').css('left');
and then
var theCar = $allImages.data('name')=="myCar".css('left');
but I think the syntax is wrong; how do I select it please?
thanks

Violet_82 89 Posting Whiz in Training

thanks for your help, I have found it but I am not entirely sure the API is helping me, sorry perhaps I still need to get used to the API. I have found this
reply = keyboard.findWithinHorizon(".",0).charAt(0); but I am not entirely sure I understand it. The methid takes 2 parameters (String pattern,int horizon) which in my case are "." and "0", but what do they do in my case? I mean how am I supposed to "read" this line reply = keyboard.findWithinHorizon(".",0).charAt(0);? The variable reply gets the input from the keyboard and we take what's in 0 position?
thanks

Violet_82 89 Posting Whiz in Training

Thanks stultuske, it's not my code, it comes from a book I am reading http://users.drew.edu/bburd/JavaForDummies/ , so I am just trying to understand this : - ).
I think I now understand the loop, which will continue to loop if the anser isn't y or n but anything else
thanks

Violet_82 89 Posting Whiz in Training

thanks, where is the advanced option (please see screenshot wordpress )

thanks

Violet_82 89 Posting Whiz in Training

Hi I am having some problem understanding the do-while loop in the following program, and I was hoping for some help:

import java.io.File;
import static java.lang.System.out;
import java.util.Scanner;

class DeleteEvidence {

   public static void main(String args[]) {
      File evidence = new File("c:\\cookedBooks.txt");
      Scanner keyboard = new Scanner(System.in);
      char reply;

      do {
         out.print("Delete evidence? (y/n) ");
         reply = 
            keyboard.findWithinHorizon(".",0).charAt(0);
      } while (reply != 'y' && reply != 'n');

      if (reply == 'y') {
         out.println("Okay, here goes...");
         evidence.delete();
         out.println("The evidence has been deleted.");
      } else {
         out.println("Sorry, buddy. Just asking.");
      }
   }
}

Basically I know how the do-while loop works, as in it executes one time and then checks the conditions. In here the condition is while (reply != 'y' && reply != 'n'); and this is throwing me a little: so we want the program to display this out.print("Delete evidence? (y/n) "); only when the answer is not 'y' and not 'n'? Am I understanding this correctly?
thanks

Violet_82 89 Posting Whiz in Training

Hi there, I am trying to find an explanation for what the findWithinHorizon() does. I landed on this page http://docs.oracle.com/javase/7/docs/api/ and I know that the method is part of the java.util.Scanner class (isn't it?). How do I find it in the page above please?
thanks

Violet_82 89 Posting Whiz in Training

Ah, what a donkey I am! Sorry, didn't think about that!
thanks

Violet_82 89 Posting Whiz in Training

you mean like a script to convert it into lower case?

Violet_82 89 Posting Whiz in Training

That's correct pritaeas in that users will upload the pdf through a cms when needed. As you correctly says, yes, it will be much easier to ensure everything is lower case, but because I effectively won't have control on what goes on the site (in that I can't force users to use lower case .pdf), I have to ensure that the code is as robust as possible and take into account human error, if we want to call it like that. This rule ul a[href$=".pdf"]{...} unfortunately isn't that robust, so I was hoping to find a good alternative (regex was the only one that come in mind without using any javascript of course) to replicating effectively the same rule 8 times
thanks