ValleyFlyer/main.rs
1// -!- rust -!- //////////////////////////////////////////////////////////////
2//
3// System :
4// Module :
5// Object Name : $RCSfile$
6// Revision : $Revision$
7// Date : $Date$
8// Author : $Author$
9// Created By : Robert Heller
10// Created : 2025-10-14 16:15:25
11// Last Modified : <251015.1045>
12//
13// Description
14//
15// Notes
16//
17// History
18//
19/////////////////////////////////////////////////////////////////////////////
20// Copyright (C) 2025 Robert Heller D/B/A Deepwoods Software
21// 51 Locke Hill Road
22// Wendell, MA 01379-9728
23//
24// This program is free software; you can redistribute it and/or modify
25// it under the terms of the GNU General Public License as published by
26// the Free Software Foundation; either version 2 of the License, or
27// (at your option) any later version.
28//
29// This program is distributed in the hope that it will be useful,
30// but WITHOUT ANY WARRANTY; without even the implied warranty of
31// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32// GNU General Public License for more details.
33//
34// You should have received a copy of the GNU General Public License
35// along with this program; if not, write to the Free Software
36// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
37//
38//
39//////////////////////////////////////////////////////////////////////////////
40use time_table::TimeTableSystem;
41
42fn InsertStations(time_table: &mut TimeTableSystem) {
43 time_table.AddStation(String::from("Greenfield, MA"),0.0);
44 time_table.AddStation(String::from("Northampton, MA"),25.0);
45 time_table.AddStation(String::from("Holyoke, MA"),15.0+25.0);
46 time_table.AddStation(String::from("Springfield, MA"),28.0+15.0+25.0);
47}
48
49fn InsertSouthboundTrains(time_table: &mut TimeTableSystem) {
50 time_table.AddTrain(String::from("Valley Flyer"),String::from("479"),60,1,
51 18*60+5,0,3).expect("Failed to insert 479");
52 time_table.AddTrain(String::from("Valley Flyer"),String::from("425"),60,1,
53 6*60+5,0,3).expect("Failed to insert 425");
54}
55
56fn InsertNorthboundTrains(time_table: &mut TimeTableSystem) {
57 time_table.AddTrain(String::from("Valley Flyer"),String::from("494"),60,1,
58 21*60+25,3,0).expect("Failed to insert 494");
59 time_table.AddTrain(String::from("Valley Flyer"),String::from("486"),60,1,
60 15*60+15,3,0).expect("Failed to insert 486");
61}
62
63
64
65
66
67fn main() {
68 let mut valley_flyer = TimeTableSystem::new(String::from("Northern NE"),
69 1440,15);
70 InsertStations(&mut valley_flyer);
71 println!("Number of Stations: {}",valley_flyer.NumberOfStations());
72 InsertSouthboundTrains(&mut valley_flyer);
73 println!("Number of trains after InsertSouthboundTrains: {}",valley_flyer.NumberOfTrains());
74 InsertNorthboundTrains(&mut valley_flyer);
75 println!("Number of trains after InsertNorthboundTrains: {}",valley_flyer.NumberOfTrains());
76 valley_flyer.SetPrintOption("DirectionName","Southbound");
77 valley_flyer.CreateLaTeXTimetable("ValleyFlyer.tex")
78 .expect("Failed to create time table LaTeX file");
79}