use rusistor::{Color, Resistor};
#[allow(dead_code)]
fn main() {
let resistor = Resistor::try_create(vec![
Color::Red, Color::Violet, Color::Black, Color::Gold, ])
.expect("Valid 4-band resistor");
let specs = resistor.specs();
println!("Resistor Specifications:");
println!("Ohms: {}", specs.ohm);
println!("Tolerance: ±{}%", specs.tolerance * 100.0);
println!("Min Ohms: {}", specs.min_ohm);
println!("Max Ohms: {}", specs.max_ohm);
let auto_resistor = Resistor::determine(
470.0, Some(0.05), None, )
.expect("Valid resistor");
println!("\nAuto-generated Resistor Bands:");
for (idx, band) in auto_resistor.bands().iter().enumerate() {
println!("Band {}: {}", idx + 1, band);
}
let zero_ohm = Resistor::try_create(vec![Color::Black]).expect("Zero ohm resistor");
let three_band = Resistor::try_create(vec![Color::Blue, Color::Grey, Color::Pink])
.expect("Three-band resistor");
let six_band = Resistor::try_create(vec![
Color::Green,
Color::Blue,
Color::Black,
Color::Black,
Color::Brown,
Color::Grey,
])
.expect("Six-band resistor");
let modified_resistor = three_band
.with_color(Color::Red, 2)
.expect("Modified resistor");
println!("\nColor Manipulation Example:");
println!("Original bands: {:?}", three_band.bands());
println!("Modified bands: {:?}", modified_resistor.bands());
}