While this is clearly not actual code, you can still tell a lot from this "pseudocode". For example, it is clear that you will need the Street instance, and from that you will need an accessor method for the lanes. Furthermore, each lane will need to have a public method that returns whether or not it is clear. This sort of analysis helps to see where you may have missed important methods or parameters. Furthermore, the method itself will involve loops and control statements.private boolean shouldCross(Street s) {
for all lanes in the street {
check if that lane is clear;
if not, then return false;
} otherwise
return true;
}
Verbal Description | Corresponsing Diagram |
---|---|
![]() | ![]() |
ClassName.java
< FILE HEADER > < Class Header > public class ClassName { < class constant data declarations and assignments > < other data member declarations > < constructors > < public and/or class method declarations and definitions > < other method declarations and definitions > < the toString() method (for instantiable classes) > } |