The Eureka Moment
The Eureka Moment
(OP)
So as you may recall I have posted several threads in this forum trying to understand OOP and I wanted to share with everyone my "Eureka Moment"!! I have been reading Head First Java for the past week or so and I'm getting towards the end and I see an example for a Jukebox and it's songs and the light bulb finally came on!
I immediately saw how an assignment I was given today should be done! The constructors, the test class, the getters and setters, everything just came together!
So I want to thank all of you that helped in creating the foundation that the Head First book was able to build on in such a way that I GET IT!!!
Here's my first new class!! It doesn't really DO very much yet, but I'll get to that, for now I'm just FRICKIN' THRILLED THAT I GET IT!! Of course if you see something that I'm doing wrong, please feel free to burst my bubble!!
public class ScannedImageFolder {
public String currentFolder;
private int imageCount;
private boolean timeToChange = false;
ScannedImageFolder(String c){
currentFolder = c;
}
public String getCurrentFolder (){
return currentFolder;
}
public void setCurrentFolder(String c){
currentFolder = c;
}
private void setImageCount() {
//code to get # of files
//imageCount = # of files;
imageCount = 11500;
}
private void settimeToChange () {
if (imageCount > 12000){
timeToChange = true;
}
}
}
And suggestions on how to take in a location=
currentFolder = "\\srvname\images\Citations\0000044"
and find that location and get the number of files in that folder?
I immediately saw how an assignment I was given today should be done! The constructors, the test class, the getters and setters, everything just came together!
So I want to thank all of you that helped in creating the foundation that the Head First book was able to build on in such a way that I GET IT!!!
Here's my first new class!! It doesn't really DO very much yet, but I'll get to that, for now I'm just FRICKIN' THRILLED THAT I GET IT!! Of course if you see something that I'm doing wrong, please feel free to burst my bubble!!
CODE
public class ScannedImageFolder {
public String currentFolder;
private int imageCount;
private boolean timeToChange = false;
ScannedImageFolder(String c){
currentFolder = c;
}
public String getCurrentFolder (){
return currentFolder;
}
public void setCurrentFolder(String c){
currentFolder = c;
}
private void setImageCount() {
//code to get # of files
//imageCount = # of files;
imageCount = 11500;
}
private void settimeToChange () {
if (imageCount > 12000){
timeToChange = true;
}
}
}
And suggestions on how to take in a location=
currentFolder = "\\srvname\images\Citations\0000044"
and find that location and get the number of files in that folder?
RE: The Eureka Moment
I'm not fimilar with java, I'm a c# dev. with .net there is a System.IO namespace which contains all kinds of objects for files and streams. If java contains a similar namespace I would start there and look for an object which accesses Directories (or Files, or both)
for example in .net there is the DirectoryInfo (intance) and Directory (static) objects which allow me to acess a director path. from there I can modify the directory and access files/subdirectories.
With your speicific example I would make the directory path a read only property that must be included when the object is instantiated. If the user needs to change directrories, return a new ScannedImageFolder.
Jason Meckley
Programmer
Specialty Bakers, Inc.
RE: The Eureka Moment
Jason Meckley,
Any relationship to Jim Meckley in Williamsport?
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: The Eureka Moment
Jason Meckley
Programmer
Specialty Bakers, Inc.
RE: The Eureka Moment
Thanks for responding.
Skip,
Just traded in my old subtlety...
for a NUANCE!