2.0 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			2.0 KiB
		
	
	
	
	
	
	
	
Hints
General
- Read about structs in the Getting Started guide.
 - Read about 
defstructin the documentation. - Watch Elixir Casts - #106: Intro to Structs.
 
1. Create a brand-new remote controlled car
- The module attribute 
@enforce_keyscan be used to specify required values. It needs to be defined before callingdefstruct. - The 
nicknamefield should not have a default value specified. - The 
new/0function should initialize thenicknamewith the value"none". 
2. Create a brand-new remote controlled car with a nickname
- Use 
multiple-function-clausesto reuse the function name but accept different arguments. - Consider a 
default-argumentfor the function. 
3. Display the distance
- For functions which accept only a specific type of struct, make sure you perform a pattern match to check the argument.
 - Use the static access operator to obtain field values.
 
4. Display the battery percentage
- For functions which accept only a specific type of struct, make sure you perform a pattern match to check the argument.
 - Use the static access operator to obtain field values.
 
5. Driving changes the battery and distance driven
- For functions which accept only a specific type of struct, make sure you perform a pattern match to check the argument.
 - Use the static access operator to obtain field values.
 - Review the introduction for updating structs.
 
6. Account for driving with a dead battery
- If the battery is dead, it should return the struct unchanged.