Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The Eureka Moment

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
0
0
US
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!!

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=
[tt]currentFolder = "\\srvname\images\Citations\0000044"[/tt]

and find that location and get the number of files in that folder?

Leslie

Have you met Hardy Heron?
 
It's always a greate moment when the light bulb turns on:) It's been my experience that the frequency of "Aha" increases the more you learn.

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.
 




Jason Meckley,

Any relationship to Jim Meckley in Williamsport?


Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
none that I'm aware of.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 


Thanks for responding.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top