I have a project to write for my school It is a program to Create a monitoring system that does all of the following:
Asks a user if they want to monitor an animal, monitor a habitat, or exit
Displays a list of animal/habitat options (based on the previous selection) as read from either the animals or habitats file
Displays the monitoring information by finding the appropriate section in the file
Separates sections by the category and selection (such as “Animal - Lion” or “Habitat - Penguin”)
Uses a dialog box to alert the zookeeper if the monitor detects something out of the normal range
Allows a user to return to the original options
I have to write pseudo code first for this program. I am not asking for someone to write this however I am asking for some hints, assistance in the style of the code and suggestions on methods and classes.
My ideas are a basic one. I am an employee and I come into relieve the night person. So I log in with credentials, and then check on maybe 3 animals. What their weight is compared to 24 hours before, what they ate and how much, and possibly some kind of exercise. I think that would be enough for a beginning program. However, if there is more suggestions to make it more useful, I am open to it.
Great! Now one more step before pseudocode: explain what you want to do like you're speaking to a young child. Each step should be logical, simple, and cover all bases. Then turn this algorithm into pseudocode, that is, how would a computer do this without using a specific programming language. Then turn the pseudocode into Java.
As you become more experienced, you can often leave out the pseudocode step.
Mark Georgevich wrote:
I have to write pseudo code first for this program. I am not asking for someone to write this however I am asking for some hints, assistance in the style of the code and suggestions on methods and classes.
My advice is to not put the cart before the horse. When you focus right away on "style of the code, ... methods and classes" then you're setting yourself up for a lot of confusion.
Focus first on outcomes. That is, think about what you as a user of the program want to do that is of value/benefit to you. Then think about how a program can help you achieve your goal and give you that value/benefit. Focusing on outcomes help you think more generally about the problem and its solution and avoid getting trapped in a labyrinth implementation details that often turns into a quagmire of complexity.
What value are you getting out of this as the author of the software? What's your goal? Obviously, as a student, your ultimate goal is to learn how to write programs but what specifically about writing programs do you want to learn through implementing this program? For example, you said you'd like to "log in with credentials". Ask yourself, "Why?" Is that really necessary now? How will adding a feature that allows the user to "log in with credentials" help you achieve your learning goal? Is that something that you want to tackle now, with the level of learning that you currently have? Or is there something else that would be more useful for your learning level and learning goals?
As far the program you want to write itself, why do you think a "log in with credentials" feature is necessary? Is authentication and authorization really a big concern in this program to monitor an imaginary zoo and the animals in it? Wouldn't it be more useful to think about other features instead, features that are more directly related to the monitoring of these imaginary animals? Like how is this program supposed to simulate data coming in from the "habitats"? Is this going to be read from a file? I know you said that the list of animals and habitats are to be read from a file but what about updates? If you're monitoring something, the assumption is that the state will change as time passes. Is the user going to enter the new data? Are they going to have to choose a different file? How often is this supposed to happen? Is this supposed to feel like it's in real time or is it some kind of "push a button to get updates" type thing?
How is the data supposed to be presented to the user? How is that information supposed to help them or be of value to them? Do you see how many questions I can come up with just about the main requirements itself? I haven't even touched on those details like logging in with credentials yet. And yet, that's the first thing you asked about. I find it interesting how easy it is to focus on something that's really not very important -- and I'm not saying that all those questions I just listed out are about the really important things either but I think they deserve more attention, at least at the start, than something like logging in with credentials.
Think about these things for a minute and let us know what your learning goals are here and what you think are the more important/valuable features of this program. Then maybe you can start thinking about classes and methods and such.
1. When I learned how to program, "Structured Analysis and Design" was the order of the day. Through that, I learned about functional decomposition, modularization, and managing complexity. I learned that large chunks of code that do many things are BadThings™ and that they pose many different kinds of problems, the least of which is harboring and hiding nasty bugs.
2. It seems to me that the above concepts have somehow been lost in the shuffle of trying to teach people how to program these days. If you look at any posting of code in these forums, you'll see a lot of code that never would have passed muster with the instructors I had back in the day. The main things that are missing: good organization, good structure, and good presentation (I'm talking about indentation and formatting). You see code where everything is jammed into one or two methods. The code is convoluted and complex. Now, I'm not saying we didn't write bad code when we started learning to program. But heck, many professionals these days still write pretty bad code even after many years of "professional work". That is no excuse for new programmers to follow the same path though. You should try to learn how to do the right things and do things right.
3. Think of yourself as an author because that's what you're aspiring to be when you set out to learn how to program. There's even a JavaDoc @author tag that you're supposed to use to proudly mark and claim responsibility for the code that you write. Take that title seriously. Good authors know how to organize their work so that it's coherent and understandable by other people who read it. If the work doesn't have those qualities, then it's trash. If you're going to be an author, then don't just learn about grammar and spelling (what you're doing when you learn the syntax and language rules). Also learn about composition (what you do when you think about organization, structure, and modularization). Good programmers and authors know a lot about good composition. That's what separates the real writers from the hacks.
I believe that I am working on the same assignment.
I'm going to try to answer some of the questions that were posed (at least from my perspective).
The point of pseudocode is to act as a sort of outline for the code that will be written later, it's a means of putting your ideas down
in a manner that can be easily understood and transferred into workable code. A difficulty that I have is that when I write a paper
I don't find outlines to be helpful, and when I'm "forced" to submit one, I tend to work backward from the paper that I've already written.
I'm finding this to be difficult when it comes to coding.
I have a similar requirement to what the OP posted.
In the assignment, there are two options for the code/ program to be written.
Option 1 is to create an authentication system that does several things:
ask for username/ password (authentication)
converts the password to MDS has (not sure what this is)
checks the credentials against a list of valid credentials provided in a file
limits the number of failed login (3) attempts before forcing an exit
gives authenticated users access to the correct files
if admin allow access to admin files
if zookeeper allow access to zookeeper files
allows a user to log out
Option 2: create a monitoring system for the animals and habitat
prompt user to input if they wish to monitor animals, habitat, or exit
display a list of options based on the selection as read from provided files (animal or habitat text files)
prompt user to input their choice
display monitoring info by finding the appropriate section in the file
separate sections by the category selected
user a dialog box to notify zookeeper if the monitor detects an abnormality (depicted by "****" in the file)
allows the user to return to the original options
Extra animals and habitats may be added, but the one provided must be used
I have chosen to pursue Option 2.
I have reviewed a lot of info on pseudocode, and I'm still struggling with it. Below is what I have so far, and I'm not sure I'm even on the right track.
CLASS FinalProject
LOOP until exit requested
EXECUTE showOptions
IF Option 1
Animals
ELSE IF Option 2
Habitats
ELSE IF Option 3
Exit
END LOOP
METHOD showOptions
LOOP until valid input received
DISPLAY 1 for Animals
DISPLAY 2 for Habitats
DISPLAY 3 to Exit
GET userInput
END LOOP
END METHOD
END CLASS
CLASS Animals
READ Animals.txt
// I"m stuck here, but with a bit more thought I think I can figure it out
END CLASS
CLASS Habitat
READ Habitat.txt
// same deal
END CLASS
Am I at least on the right track?
I am thinking I will be using real expressions to pick out key characters or possibly do it with a char or key words (still working on this)
Junilu Lacar wrote:Mostly on the right track, I think. The trick is to write some code and see it work first. Start with the menu and at least get the flow right.
Thanks Junilu
Once again you're a HUGE help
Post by:autobot
moose poop looks like football shaped elk poop. About the size of this tiny ad:
a bit of art, as a gift, the permaculture playing cards