public Boat(BoatType type, double length)
        {
            this.Initialize();

            m_type = type;
            m_length = length;
        }
Ejemplo n.º 2
0
        internal static int GetNumPositionsForBoatType(BoatType type)
        {
            int retval = 0;

            switch (type)
            {
            case BoatType.RowingBoat:
                retval = 1;     // Not exactly true since it takes just 0.5, but we handle that elsewhere
                break;

            case BoatType.PowerBoat:
                retval = 1;
                break;

            case BoatType.SailBoat:
                retval = 2;
                break;

            case BoatType.Catamaran:
                retval = 3;
                break;

            case BoatType.CargoBoat:
                retval = 4;
                break;

            default:
                break;
            }
            return(retval);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// This will get all of the drivers with a specific type of boat.
 /// </summary>
 /// <param name="boatType">This is the boat type of the driver.</param>
 /// <returns>This returns the Id, First Name, Last Name, Location, Days Available, Type of Boat, Maximum Occupancy and Hourly Rate of all of the drivers with a specific type of boat.</returns>
 public IEnumerable <DriverDetailTwo> GetDriversByBoatType(BoatType boatType)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var query =
             ctx
             .Drivers
             .Where(e => e.TypeOfBoat == boatType)
             .Select(e => new DriverDetailTwo
         {
             DriverId          = e.DriverId,
             ApplicationUser   = e.ApplicationUser,
             UserCreatedDriver = e.UserCreatedDriver,
             DriverFirstName   = e.DriverFirstName,
             DriverLastName    = e.DriverLastName,
             Location          = e.Location,
             DaysAvailable     = e.DaysAvailable,
             TypeOfBoat        = e.TypeOfBoat,
             MaximumOccupants  = e.MaximumOccupants,
             HourlyRate        = e.HourlyRate,
             DriverRatings     = e.DriverRatings,
             LoggedInUser      = ctx.Users.FirstOrDefault(d => d.Id == _userId.ToString()).UserName
         });
         return(query.ToArray());
     }
 }
        public void RegisterBoat(BoatType boatType, double length, Member member)
        {
            var boat = new Boat(boatType, length);

            member.RegisterBoat(boat);
            _db.Save();
        }
Ejemplo n.º 5
0
        public ReadOnlyCollection <Member> GetMembers()
        {
            List <Member> members = new List <Member>();

            XmlNodeList memberNodes = _doc.SelectNodes("//memberRegistry/member");

            foreach (XmlNode memberNode in memberNodes)
            {
                List <Boat> boats   = new List <Boat>();
                int         id      = int.Parse(memberNode.Attributes["id"].Value);
                string      name    = memberNode.Attributes["name"].Value;
                string      pNumber = memberNode.Attributes["personalNumber"].Value;

                foreach (XmlNode boat in memberNode.ChildNodes)
                {
                    string   typeString = boat.Attributes["type"].Value;
                    BoatType boatType   = (BoatType)Enum.Parse(typeof(BoatType), typeString);
                    int      length     = int.Parse(boat.Attributes["length"].Value);
                    int      boatId     = int.Parse(boat.Attributes["id"].Value);
                    boats.Add(new Boat(boatType, length, boatId));
                }

                members.Add(new Member(name, pNumber, id, boats));
            }
            return(members.AsReadOnly());
        }
Ejemplo n.º 6
0
        public IHttpActionResult GetByBoatType(BoatType boatType)
        {
            DriverService driverService = CreateDriverService();
            var           drivers       = driverService.GetDriversByBoatType(boatType);

            return(Ok(drivers));
        }
Ejemplo n.º 7
0
    public void RemoveBoat(BoatType b)
    {
        switch (b)
        {
        case BoatType.Kayak:
            if (RegularSlots.Contains(BoatType.Kayak))
            {
                RegularSlots.Remove(RegularSlots.FindLast(x => x == BoatType.Kayak));
            }
            break;

        case BoatType.Canoe:
            if (RegularSlots.Contains(BoatType.Canoe))
            {
                RegularSlots.Remove(RegularSlots.FindLast(x => x == BoatType.Canoe));
            }
            else
            {
                if (CanoeSlots.Contains(BoatType.Canoe))
                {
                    CanoeSlots.Remove(CanoeSlots.FindLast(x => x == BoatType.Canoe));
                }
            }
            break;
        }
    }
Ejemplo n.º 8
0
        public List <Member> ReadFromFile()
        {
            List <Member> myList = new List <Member>();

            if (File.Exists(path))
            {
                Member thisMember  = new Member(" member", " ", 0);
                int    memberIndex = -1;
                foreach (string line in File.ReadLines(path))
                {
                    if (line.StartsWith(" "))
                    {
                        string[] boat = line.Split(',');
                        boat[0] = boat[0].Substring(3);
                        boat[1] = boat[1].Substring(1);
                        boat[2] = boat[2].Substring(1);
                        BoatType type = BoatType.KajakCanoe;
                        Enum.TryParse(boat[0], out type);
                        myList[memberIndex].boats.Add(new Boat(Int32.Parse(boat[1]), Int32.Parse(boat[2]), type));
                        myList[memberIndex].NumberOfBoats++;
                    }
                    else
                    {
                        string[] member = line.Split(',');
                        member[1]  = member[1].Substring(1);
                        member[2]  = member[2].Substring(1);
                        thisMember = new Member(member[0], member[1], Int32.Parse(member[2]));
                        myList.Add(thisMember);
                        memberIndex++;
                    }
                }
            }
            return(myList);
        }
Ejemplo n.º 9
0
        public void ChangeBoat(Boat b, int t, int l)
        {
            BoatType type = b.PickBoatType(t);

            b.Type         = type;
            b.LengthInFeet = l;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="p_Cells">List of cells to  be converted into a boat.</param>
        public Boat(List <Cell> p_Cells)
        {
            Cells = p_Cells;

            State = BoatState.Healthy;

            foreach (var cell in p_Cells)
            {
                cell.ParentBoat = this;
            }

            if (Cells.Count == 4)
            {
                Type = BoatType.Battleship;
            }
            else if (Cells.Count == 3)
            {
                Type = BoatType.Cruiser;
            }
            else if (Cells.Count == 2)
            {
                Type = BoatType.Destroyer;
            }
            else if (Cells.Count == 1)
            {
                Type = BoatType.Torpedoboat;
            }
            else
            {
                //TODO
                //AliensShip in our Fleet!
            }
        }
        /// <summary>
        /// Adds boat to a member
        /// </summary>
        public void AddBoat()
        {
            BoatTypeMenu boatTypeMenu = new BoatTypeMenu();

            string pId = _boatView.InputSsn();

            if (!IsCorrectInputOfSsn(pId))
            {
                AddBoat();
            }
            else
            {
                BoatRegister boatRegister = MemberRegister.GetMemberBySsn(pId).BoatRegister;
                boatTypeMenu.DisplayMenu();
                BoatType boatType = boatTypeMenu.GetInput();

                string lengthString = _boatView.InputBoatLength();

                if (ConvertToDouble(lengthString) == 0)
                {
                    _boatViewWrongInputMessages.PrintNotADoubleAboveZero();
                    AddBoat();
                }
                else
                {
                    boatRegister.AddBoat(boatType, ConvertToDouble(lengthString));
                    _boatView.PrintActionSuccess();
                }
            }
        }
Ejemplo n.º 12
0
 public Boat(BoatType boatType, int lives)
 {
     BoatType    = boatType;
     BoatLives   = new bool[lives];
     IsSunk      = false;
     Orientation = Orientation.Horizontal;
 }
        public async Task <IActionResult> Edit(int id, [Bind("BoatTypeId,Name,Description,Chargeable,Sail,Image")] BoatType boatType)
        {
            if (id != boatType.BoatTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(boatType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BoatTypeExists(boatType.BoatTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(boatType));
        }
Ejemplo n.º 14
0
        public Boat(string name, int maxCapacity, BoatType boatType)
        {
            this.Name        = name;
            this.MaxCapacity = maxCapacity;
            this.BoatType    = boatType;

            this.CrewMembers = new List <Crew>();
        }
Ejemplo n.º 15
0
 public Boat(int id, string name, BoatType type, int longitude, int latitude)
 {
     Id = id;
     Name = name;
     Type = type;
     Longitude = longitude;
     Latitude = latitude;
 }
Ejemplo n.º 16
0
        public bool AddNewBoat(string _boatName, BoatType _type)
        {
            BoatStats _newBoatStats = new BoatStats(_type);

            _boatName += (" " + TroopUtility.IntToRomanNumeral(AddNameToDatabase(_boatName)));
            _newBoatStats.boatName = _boatName;
            boats.Add(_newBoatStats);
            return(true);
        }
 public void PrintBoatInformation(int reference, BoatType type, double length, int id)
 {
     Console.ForegroundColor = ConsoleColor.DarkMagenta;
     Console.WriteLine();
     Console.WriteLine(reference + ". Boat type: " + type);
     Console.WriteLine("   Boat length: " + length);
     Console.WriteLine("   Boat id: " + id);
     Console.WriteLine("__________");
 }
Ejemplo n.º 18
0
                    static Boat GetBoat(BoatType type)
                    {
                        Boat boat = new Boat();

                        string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

                        string prefix = "";

                        switch (type)
                        {
                        case BoatType.RoddBoat:
                            prefix           = "R-";
                            boat.Weight      = random.Next(100, 300);
                            boat.MaxSpeed    = random.Next(1, 3);
                            boat.DockingDays = 1;
                            boat.SlotSize    = 0.5;
                            break;

                        case BoatType.MotorBoat:
                            prefix           = "M-";
                            boat.Weight      = random.Next(200, 3000);
                            boat.MaxSpeed    = random.Next(1, 60);
                            boat.DockingDays = 3;
                            boat.SlotSize    = 1.0;
                            break;

                        case BoatType.SegelBoat:
                            prefix           = "S-";
                            boat.Weight      = random.Next(800, 6000);
                            boat.MaxSpeed    = random.Next(1, 12);
                            boat.DockingDays = 4;
                            boat.SlotSize    = 2.0;
                            break;

                        case BoatType.LastFartyg:
                            prefix           = "L-";
                            boat.Weight      = random.Next(3000, 20000);
                            boat.MaxSpeed    = random.Next(1, 20);
                            boat.DockingDays = 6;
                            boat.SlotSize    = 4.0;
                            break;

                        default:
                            prefix = "D-";
                            break;
                        }

                        var list = Enumerable.Repeat(0, 3).Select(x => chars[random.Next(chars.Length)]);

                        string result = string.Join("", list);

                        boat.ID   = prefix + result;
                        boat.Type = type;

                        return(boat);
                    }
Ejemplo n.º 19
0
        public void selectAndUpdateBoat(int boatChoice, BoatType boatType, string length)
        {
            Boat boat = boats.FirstOrDefault(x => x.BoatID == boatChoice);

            if (boat != null)
            {
                boat.BoatType = boatType;
                boat.Length   = length;
            }
        }
Ejemplo n.º 20
0
 public BoatStats(string _name, BoatType _type, int _tCap, int _lCap, float _knots, int _hp)
 {
     boatName      = _name;
     boatType      = _type;
     troopCapacity = _tCap;
     lootCapasity  = _lCap;
     knots         = _knots;
     health        = _hp;
     sprite        = Resources.Load <Sprite>(_type.ToString());
 }
Ejemplo n.º 21
0
 public Boat(BoatType type, int length, int boatId)
 {
     if ((!Enum.IsDefined(typeof(BoatType), type)))
     {
         throw new ArgumentOutOfRangeException("A Boat can only be instantiated with defined BoatType");
     }
     Type   = type;
     Length = length;
     Id     = boatId;
 }
Ejemplo n.º 22
0
        private void LoadBoatTypes()
        {
            List <BoatType> types = BoatType.FindAll();

            typeCB.Items.Clear();
            foreach (BoatType t in types)
            {
                typeCB.Items.Add(t);
            }
        }
        public async Task <IActionResult> Create([Bind("TypeID,TypeName")] BoatType boatType)
        {
            if (ModelState.IsValid)
            {
                _context.BoatTypes.Add(boatType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(boatType));
        }
        public async Task <IActionResult> Create([Bind("BoatTypeId,Name,Description,Chargeable,Sail,Image")] BoatType boatType)
        {
            if (ModelState.IsValid)
            {
                _context.Add(boatType);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(boatType));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Constructor
        /// Initialises a new Boat with expected properties
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="length"></param>
        public Boat(string name, BoatType type, int length)
        {
            Condition.Requires(name).IsNotNullOrWhiteSpace();
            Condition.Requires(length).IsGreaterOrEqual(1);

            Id     = Guid.NewGuid();
            Name   = name;
            Type   = type;
            Length = length;
            Hits   = 0;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Creates a new boat and calls the database class to add it to the database.
        /// </summary>
        /// <param name="boatType">A BoatType enum.</param>
        /// <param name="length">The boat length.</param>
        public void AddBoat(BoatType boatType, double length)
        {
            Boat newBoat = new Boat()
            {
                Type   = boatType,
                Length = length,
                BoatId = GenerateId()
            };

            Database.AddBoat(newBoat, _ownerPersonalId).Wait();
        }
Ejemplo n.º 27
0
 public BoatDataFactory(
     DataController dataController,
     MemberData member,
     int length,
     BoatType type) :
     base(dataController)
 {
     this.member = member;
     this.length = length;
     this.type   = type;
 }
Ejemplo n.º 28
0
        public void EditBoat(BoatType newType, double newLength)
        {
            List <Member> existingMembers = _storage.ReadFile();

            Member memberToEdit = existingMembers[SelectedMemberIndex];
            Boat   boatToEdit   = memberToEdit.Boats[SelectedBoatIndex];

            boatToEdit.Type   = newType;
            boatToEdit.Length = newLength;

            _storage.WriteFile(existingMembers);
        }
Ejemplo n.º 29
0
        public void AddBoat(BoatType type, double length)
        {
            List <Member> existingMembers = _storage.ReadFile();

            Member memberToAddBoat = existingMembers[SelectedMemberIndex];

            Boat newBoat = new Boat(type, length);

            memberToAddBoat.Boats.Add(newBoat);

            _storage.WriteFile(existingMembers);
        }
Ejemplo n.º 30
0
        public BoatStats(BoatType _type)
        {
            BoatStats _newStats = GetStatsForType(_type);

            boatName      = _newStats.boatName;
            boatType      = _newStats.boatType;
            troopCapacity = _newStats.troopCapacity;
            lootCapasity  = _newStats.lootCapasity;
            knots         = _newStats.knots;
            health        = _newStats.health;
            sprite        = Resources.Load <Sprite>(_type.ToString());
        }
Ejemplo n.º 31
0
        public void SetBoatData(string targetID, string ownerID, int length, BoatType type)
        {
            BoatData bd = (BoatData)RetrieveByID(targetID);

            if (ownerID != null)
            {
                ((MemberData)RetrieveByID(ownerID)).RegisterBoat(bd);
            }
            bd.Length   = length;
            bd.BoatType = type;
            fileController.SaveToFile(bd);
        }
        /// <summary>Method <c>CreateBoat</c> Gets the Boat type and Boat length from the User, then creates a Boat object</summary>
        public Boat CreateBoat()
        {
            BoatType boatType   = _boatView.GetBoatType();
            double   boatLength = _boatView.GetBoatLength();
            Boat     boat       = new Boat
            {
                BoatType = boatType,
                Length   = boatLength
            };

            return(boat);
        }
Ejemplo n.º 33
0
 public void Update(double length, BoatType type)
 {
     Length = length;
     BoatType = type;
 }
Ejemplo n.º 34
0
 public int AddBoat(double length, BoatType type)
 {
     var boat = new Boat(length, type);
     Boats.Add(boat);
     return Boats.Count - 1;
 }
Ejemplo n.º 35
0
        /// <summary>
        /// <para>Performs the Search Method:
        /// Search Motor Boats
        /// using the parameters provided - can use null if the parameter is not required.
        /// </para>
        /// DOES NOT REQUIRE AUTHENTICATION.
        /// </summary>
        /// <param name="searchString">One or more keywords to use in a search query.</param>
        /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param>
        /// <param name="priceMin">Minimum price.</param>
        /// <param name="priceMax">Maximum price.</param>
        /// <param name="type">Type of the Motor Boat.</param>
        /// <param name="lengthMin">Minimum length of a boat in metres.</param>
        /// <param name="lengthMax">Maximum length of a boat in metres.</param>
        /// <param name="dateFrom">Return only listings started from this date.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rows">Number of rows per page.</param>
        /// <returns>MotorBoats.</returns>
        public MotorBoats SearchMotorBoats(string searchString, SortOrder sortOrder, decimal priceMin, decimal priceMax, BoatType type, int? lengthMin, int? lengthMax, DateTime dateFrom, int? page, int? rows)
        {
            var url = String.Format(Constants.Culture, "{0}/{1}/Boats{2}", Constants.SEARCH, Constants.MOTORS, Constants.XML);
            _addAnd = false;

            // create the parameters for the query string
            var conditions = "?";
            conditions += SearchMethods.ConstructQueryHelper(Constants.SEARCH_STRING, searchString, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.SORT_ORDER, string.Empty + sortOrder, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MIN, string.Empty + priceMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PRICE_MAX, string.Empty + priceMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.TYPE, type.ToString(), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.LENGTH_MIN, string.Empty + lengthMin, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.LENGTH_MAX, string.Empty + lengthMax, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.DATE_FROM, Client.DateToStringConverter(dateFrom), _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.PAGE, string.Empty + page, _addAnd);
            conditions += SearchMethods.ConstructQueryHelper(Constants.ROWS, string.Empty + rows, _addAnd);

            // add the parameters to the query string if there are any
            if (conditions.Equals("?"))
            {
                url += conditions;
            }

            // perform the request
            return this.SearchMotorBoats(url);
        }
Ejemplo n.º 36
0
 public void Update(Boat boatInfo, double length, BoatType type)
 {
     var boat = Boats.FirstOrDefault<Boat>(b => b == boatInfo);
     boat.Update(length, type);
 }
Ejemplo n.º 37
0
        /// <summary>
        /// <para>Performs the Search Method:
        /// Search Motor Boats
        /// using the parameters provided - can use null if the parameter is not required.
        /// </para>
        /// DOES NOT REQUIRE AUTHENTICATION.
        /// </summary>
        /// <param name="searchString">One or more keywords to use in a search query.</param>
        /// <param name="sortOrder">Sort the returned record-set by a single specified sort order.</param>
        /// <param name="priceMin">Minimum price.</param>
        /// <param name="priceMax">Maximum price.</param>
        /// <param name="type">Type of the Motor Boat.</param>
        /// <param name="lengthMin">Minimum length of a boat in metres.</param>
        /// <param name="lengthMax">Maximum length of a boat in metres.</param>
        /// <param name="dateFrom">Return only listings started from this date.</param>
        /// <param name="page">Page number.</param>
        /// <param name="rows">Number of rows per page.</param>
        /// <returns>MotorBoats.</returns>
        public MotorBoats SearchMotorBoats(string searchString, SortOrder sortOrder, decimal priceMin, decimal priceMax, BoatType type, int? lengthMin, int? lengthMax, DateTime dateFrom, int? page, int? rows)
        {
            if (_search == null)
            {
                _search = new SearchMethods(_connection);
            }

            return _search.SearchMotorBoats(searchString, sortOrder, priceMin, priceMax, type, lengthMin, lengthMax, dateFrom, page, rows);
        }
Ejemplo n.º 38
0
 private string TranslateBoatType(BoatType boatType)
 {
     string ret="";
     switch (boatType)
     {
         case BoatType.Sailboat:
             {
                 ret = "Sailboat";
                 break;
             }
         case BoatType.Motorsailer:
             {
                 ret = "Motorsailer";
                 break;
             }
         case BoatType.kayak_Canoe:
             {
                 ret = "Kayak/Canoe";
                 break;
             }
         case BoatType.Other:
             {
                 ret = "Other";
                 break;
             }
     }
     return ret;
 }
Ejemplo n.º 39
0
 public Boat(BoatType boatType, int length)
 {
     Length = length;
     Boat_Type = boatType;
 }
Ejemplo n.º 40
0
 public Boat(BoatType type, int length)
 {
     Length = length;
     Type = type;
 }
Ejemplo n.º 41
0
 public void LoadMembers() {
     using (StreamReader reader = new StreamReader(path))
     {
         string line;
         MemberRepositoryStatus status = MemberRepositoryStatus.Indefinite;
         while ((line = reader.ReadLine()) != null)
         {
             if (line == string.Empty)
             {
                 continue;
             }
             // om line innehåller ett status meddelande
             if (line == "[Name]")
             {
                 status = MemberRepositoryStatus.Name;
             }
             else if (line == "[PersonalNumber]")
             {
                 status = MemberRepositoryStatus.PersonalNumber;
             }
             else if (line == "[Id]")
             {
                 status = MemberRepositoryStatus.Id;
             }
             else if (line == "[BoatType]")
             {
                 status = MemberRepositoryStatus.BoatType;
             }
             else if (line == "[BoatLength]")
             {
                 status = MemberRepositoryStatus.BoatLength;
             }
             else if (line == "[End]")
             {                 
                 members.Add(new Member(name, personalNumber, id, boats));
             }
             // line är ett namn, ett id, ett medlems nummer, en båttyp eller en båtlängd
             else
             {
                 // om medlemmens namn kommer på nästa rad
                 if (status == MemberRepositoryStatus.Name)
                 {
                     name = line;
                     boats = new List<Boat>();
                 }
                 // om personnummer kommer på nästa rad
                 else if (status == MemberRepositoryStatus.PersonalNumber)
                 {
                     personalNumber = line;
                 }
                 // om memdelmsid kommer på nästa rad
                 else if (status == MemberRepositoryStatus.Id)
                 {
                     id = int.Parse(line);
                 }
                  // om status är BoatType så...
                 else if (status == MemberRepositoryStatus.BoatType)
                 {                           
                     boatType = (BoatType)Enum.Parse(typeof(BoatType), line);                
                 }
                  // om status är BoatLength så...
                 else if (status == MemberRepositoryStatus.BoatLength)
                 {
                     boatLength = line;
                     boats.Add(new Boat(boatType, boatLength));
                 }
             }
         }
     }
 }
Ejemplo n.º 42
0
 public Boat(double length, BoatType type)
 {
     Length = length;
     Type = type;
 }
Ejemplo n.º 43
0
 public Boat(BoatType type, double length, DateTime registrationDate)
 {
     Type = type;
     Length = length;
     RegistrationDate = registrationDate.Date;
 }
Ejemplo n.º 44
0
 public Boat(BoatType boatType, string boatLength) 
 {
     BoatType = boatType;
     BoatLength = boatLength;
 }
Ejemplo n.º 45
0
Archivo: Boat.cs Proyecto: fh222dt/OOAD
 public void Set(Boat a_boat)
 {
     m_type = a_boat.m_type;
     m_length = a_boat.m_length;
 }
Ejemplo n.º 46
0
Archivo: Boat.cs Proyecto: fh222dt/OOAD
 public Boat(BoatType a_type, double a_length)
 {
     m_type = a_type;
     m_length = a_length;
 }
Ejemplo n.º 47
0
 public Boat(BoatType type, float boatLenght)
 {
     BoatTypeProp = type;
     BoatLenght = boatLenght;
 }
Ejemplo n.º 48
0
        public Boat getNewBoat()
        {
            var boatType = new BoatType();

            Console.WriteLine("1. {0}", AppStrings.boatTypeSailbot);
            Console.WriteLine("2. {0}", AppStrings.boatTypeMotorsailer);
            Console.WriteLine("3. {0}", AppStrings.boatTypeCanoe);
            Console.WriteLine("4. {0}", AppStrings.boatTypeOther);
            Console.Write(AppStrings.addBoatType);

            var correctInput = false;
            while (!correctInput)
            {
                string type = Console.ReadLine();
                switch (type)
                {
                    case "1":
                        correctInput = true;
                        boatType = BoatType.Sailboat;
                        break;
                    case "2":
                        correctInput = true;
                        boatType = BoatType.Motorsailer;
                        break;
                    case "3":
                        correctInput = true;
                        boatType = BoatType.Canoe;
                        break;
                    case "4":
                        correctInput = true;
                        boatType = BoatType.Other;
                        break;
                    default:
                        Console.Write(AppStrings.failMenuWrongChoice);
                        break;
                }
            }

            Console.Write(AppStrings.addBoatLength);
            int length;
            while (true)
            {
                if (int.TryParse(Console.ReadLine(), out length))
                {
                    return new Boat(boatType, length);
                }
                else
                    Console.Write(AppStrings.failWrongLength);
            }
        }
Ejemplo n.º 49
0
        public void ShowFormAddBoat(Member selected)
        {
            BoatType boatType;

            Console.WriteLine("**Add Boat Information**");

            foreach (BoatType boat in Enum.GetValues(typeof(BoatType)))
            {
                Console.WriteLine("{0}){1} ", (int)boat, boat);
            }
            Console.Write("Enter type: ");
            string indataType = Console.ReadLine();
            Enum.TryParse(indataType, out boatType);
            Console.Write("Enter length: ");
            string indataLength = Console.ReadLine();
            //Save to properties
            this.TypeOfBoat = boatType;
            this.Length = float.Parse(indataLength.Replace('.', ','));
        }
Ejemplo n.º 50
0
        public void UpdateBoat(Member updateFromMember, Boat toBeUpdated, BoatType type, float length)
        {
            var updateBoat = (from boat in updateFromMember.Boats
                              where boat.Id == toBeUpdated.Id
                              select boat).FirstOrDefault();

            //updateFromMember.Boats.Remove(updateBoat);

            DeleteBoat(updateFromMember, toBeUpdated);
            toBeUpdated.BoatType = type;
            toBeUpdated.Length = length;
            AddBoat(updateFromMember, toBeUpdated);

            //db.Save((List<Member>)members);
        }
Ejemplo n.º 51
0
 public Boat(BoatType boatType, float length)
 {
     this.BoatType = boatType;
     this.Length = length;
 }
Ejemplo n.º 52
0
 public Boat(BoatType Type, int Length)
 {
     this.Type = Type;
     this.Length = Length;
 }